So my batch file is supposed to do this:
I have a few hundred WinRAR generated "(NAME).part???.rar" files that i want to put into a generated folder tree.
It should put the first 10 files (from 001 to 010) into a new folder named 001 (not just 1). Then it takes the next ten (011-020) and put them into 002.
I i have fixed everything with adding the zeros automaticly, and i tested all variables but i can't get the actual file movement to work.
Here is what i'm trying to execute:
move "%FILENAME%" %LOOP2%\
%LOOP2% and is just the var %LOOP% (which starts at 1 and goes +1 every tenth loop) with all needed zeros in front of it (so 007, 035 and 455 etc.).
%FILENAME% comes from some more variables:
set FILENAME=%NAME%.part%COUNT2%.rar
%NAME% holds the name of the file/files/filepack (?) i want to move, e.g. "Splitted file.part001.rar" would be "Splitted file" (entered by user)
%COUNT2% starts at 1 and increases every loop until it matches the user-entered %NUMBER% var, which is the last file number (e.g. 468). It comes from %COUNT% which i don't want to change, so i created %COUNT2%.
I tried almost everything but sometimes cmd tells me the file or directory wasn't found or it suddenly closes displaying something with "can't syntacticly be used here" for a brief moment. (Also the message is translated from German!)
People talk lot about putting double percent signs or double quotes or no quotes and so on and i tried most combinations but still i can't get it to work. Can someone give me the right syntax and tell me where and how i have to use quotes and double percent signs?
I know my code and this text is pretty messy but i'm still learning :) Ofc i asked Dr. Google and Stackoverflow but i think my case is a bit specific.
You have not shown your code and there is no way to guess what the problem is, so I created my own:
@echo off
setlocal EnableDelayedExpansion
set /P "NAME=Enter name of file/files/filepack (NO quotes): "
set /P "NUMBER=Enter number of files to copy: "
set /A COUNT2=1000, LOOP2=1000
for /L %%i in (1,1,%NUMBER%) do (
set /A COUNT2+=1, COUNT2mod10=COUNT2 %% 10
if !COUNT2mod10! equ 1 (
set /A LOOP2+=1
md !LOOP2:~1!
)
move "%NAME%.part!COUNT2:~1!.rar" !LOOP2:~1!
)