hi i have a problem
i want to move winrar part files files to the same filename(folder) (witout part1 part2 etc) i have a code but if this code is not working right see image
@echo off & setLocal EnableDELAYedeXpansion
for /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
set F=%%a
set F=!F:~0,9!
rem if not exist "!F!" md "!F!"
move "%%a" "!F!"
)
the filenames can change all the time with less or more characters (4 to 40)
can you tell me 'the solution?
please help
thank you
help please with batch move files to folder
Moderator: DosItHelp
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: help please with batch move files to folder
It looks like you're trying to do:
English:
-For each file in the current directory, make a folder out of it's name up to the first period encountered. (If the folder exists, nothing happens but 2>nul makes no error display.)
-Move all files to the folder matching the name (same context).
Code: Select all
@echo off
for /f "delims=. tokens=1,*" %%a in ('dir/b/a-d') do (
md "%%a" 2>nul
move "%%a.%%b" "%%a"
)
English:
-For each file in the current directory, make a folder out of it's name up to the first period encountered. (If the folder exists, nothing happens but 2>nul makes no error display.)
-Move all files to the folder matching the name (same context).
Last edited by orange_batch on 27 May 2011 14:23, edited 2 times in total.
Re: help please with batch move files to folder
Code: Select all
for /f "delims=" %%f in ('dir *.part*.rar /b/a-d') do (
for /f "delims=." %%n in ("%%f") do (
if not exist "%%n" md "%%n"
move "%%f" "%%n"
)
)
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: help please with batch move files to folder
Dare I say my solution beats yours this time !k?
It affects all files in the current directory though.
It affects all files in the current directory though.
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: help please with batch move files to folder
Add a little if to keep the bat and yes orange you would be correct
Re: help please with batch move files to folder
thx for your fast answer i'll try this tomorrow morning i let you know if it works ok
Yes it works great thank you very much
Yes it works great thank you very much