1.

Solve : copy files of multiple folders and rename them?

Answer»

I have list of folders like this!


files in all the folder are named that way

I want EXTRACTING them in one folder without losing the order ([MFT]Nuit_119 to [MFT]Nuit_128)
the result will appear like this

I didn't find the way to do it with cmd because I want to do it without any software just with windowstry this:
Code: [Select]@echo off
md FULL
for /f "delims=" %%A in ('dir /b /a:d ^| find /v "FULL"') do (
cd %%A
for /f "delims=" %%B in ('dir /b') do (
echo copy "%%B" "..\FULL\%%A_p%%B"
)
cd ..
:: rd /q /s %%A
)

If you like it, remove "echo" and "::" (but only remove "::" if you want to delete the folders and files not in FULL)

It goes in the folder with [MFT]Nuit_xxx folders. will rename all the files "[MFT]Nuit_###_p##"

EDIT: make sure you don't have folders named "1" and "10" as it will order them 1,10,2,3,4,5,6,7,8,9. to get around this, MANUALLY put 0's (zeros) in front of all the numbers until they are the same number of digits 01,02,03,04,05,06,07,08,09,10. I'll look into making this automatic, but that might not be possible with only windows commands.

EDIT2: here is how you can organize them without the manual input (UNTESTED)
Code: [Select]@echo off
setlocal EnableDelayedExpansion
set name=<PUT YOUR FOLDER NAME HERE WITHOUT THE NUMBERS AT THE END>
set end=<PUT THE END NUMBER HERE>
md FULL
for /l %%Z in (1,1,%end%) do (
if exist !name!%%Z echo !name!%%Z >>tmp
)
for /f "delims=" %%A in (tmp) do (
cd %%A
for /f "delims=" %%B in ('dir /b') do (
echo copy "%%B" "..\FULL\%%A_p%%B"
)
cd ..
:: rd /q /s %%A
)
del tmp
If that doesn't work then explain how you want the 01.jpg 02.jpg etc files to be renamed. The third IMAGE gives no clue as to how they should all appear in one folder, as the filenames don't relate to the first two images at all.

Quote from: hackerwz on August 02, 2013, 09:15:45 AM

I want extracting them in one folder without losing the order ([MFT]Nuit_119 to [MFT]Nuit_128)
the result will appear like this
Quote from: foxidrive on August 02, 2013, 10:24:59 PM
If that doesn't work then explain how you want the 01.jpg 02.jpg etc files to be renamed. The third image gives no clue as to how they should all appear in one folder, as the filenames don't relate to the first two images at all.
I said that I want extracting them in one folder considering that I have a list of chapiter(Folders) of manga like narutochapter01 to narutochapter200 I wish extracting all of them at once in
one volume folder which contains nautochapter01 to chapter200's pictures
I use CDisplayEx to read manga and it doesn't support subdirectories READING pictures forcing me to switch from folder to folder therefore I have to extract file from chap01 and then rename chap02's files and extracting them .... it does not matter For the filenames I just have to use Windows to rename them in bulk
Please clarify the adjustment of the code because I am a total beginner in coding and I just learned how to say hello in cmd
PS : tell me if you find another solution like alternative softwareI forgot to thank the helpers Test this in an empty folder, that contains some test folders with the JPG pictures. It will move them all into the empty folder and rename them.

Code: [Select]@echo off
for /f "delims=" %%z in ('dir *.jpg /b /s /a-d ') do (
for %%a in ("%%~dpz%\.") do (
move "%%z" "%%~nxa_%%~nxz"
)
)


Discussion

No Comment Found