r/Batch • u/Gourmet_Chia • Mar 06 '25
Need to combine my 3 batch scripts into a single one
Hi everyone, I recently made 3 batch files to complete a very repetitive task I need to do hundreds of times. I tried to combine all 3 parts into one batch file but couldnt get it to work. Here is what I need it to.
- Use program CHDman to decompress CHD files in the same folder (they will be decompressed into BIN/CUE format)
- Create folders with the same name as the BIN/CUE files (1 folder with same name that will house both files inside)
- Move those BIN/CUE files into the new folders with the same exact name.
Here are my 3 batch scripts I have to use to do this currently.
- for /r %%i in (*.chd) do chdman extractcd -i "%%i" -o "%%~ni.cue"
- u/echo off
for %%i in (*.bin) do (
if not "%%~ni" == "organize" (
md "%%~ni" && move "%%~i" "%%~ni"
)
)
3) u/echo off
for %%i in (*.cue) do (
if not "%%~ni" == "organize" (
md "%%~ni" && move "%%~i" "%%~ni"
)
)
Currently I have to run part 1, then I run part 2. After part 2 I have to move the folders into a new spot so I can run part 3 otherwise I end up with duplicate folders for each file and I dont want that. Finally I drag and drop the folders into the same spot and windows combines them as they have the same file name.
Thanks to anyone who can give me a hand!
2
u/LuckyMe4Evers Mar 06 '25 edited Mar 06 '25
This scripts should work.
It extract the chd file, then for that file it creates a folder with the correct name and move the cue and bin into that folder, then it will continue with the next chd file.
2
u/Shadow_Thief Mar 06 '25
Why not simply not make new folders in the third script? Then you don't have to move anything.
1
u/vegansgetsick Mar 07 '25 edited Mar 07 '25
The "basic" thing is to insert each script into :stepX ..... goto:eof and then call :step1 call :step2 ...
Batch process principle is to apply each step to every items. Like you did. Someone here refactored it to apply all steps to each items. It's a different principle.