|
Answer» Hi,
I have around 2000 folders WITHIN folders and they each have 1 .jpg file in them. I want to move this .jpg file up one level and RENAME it to from its individual filename to thumb2.jpg. Deleting that subfolder is not necessary, but would be beneficial.
For EXAMPLE I have something LIKE this:
\THUMBSIZE\9488\JPEG\filenamex8393.jpg
Where the number and filename is different each time for each folder. I want to move and rename the .jpg file up one level so it looks like:
\THUMBSIZE\9488\thumb2.jpg
Is there a way to do this? Am really stuck and don't want to do all of this manually Look into 'for /r', or 'for /f' (which is less effective) as well as 'move'/'copy'/'xcopy' and 'rename'.I guess my only QUESTION i would have...not stating i have a solution...but why would you create 2000 folders with 1 image in each ? ? Just curios.Are there any JPG files in the folder tree that you *don't* want renamed and moved?
If you want to rename and move *every* .jpg file then run this, after changing the folder, which will create file.bat.txt Examine the file.bat.txt file in notepad to ensure it is doing what you need to do. If it is right then rename it to file.bat and run it.
Code: [Select]@echo off for /r "c:\main\folder\" %%a in (*.jpg) do >>file.bat.txt echo pushd "%%~dpa" ^& ren "%%~nxa" "thumb2.jpg" ^& move "thumb2.jpg" .. ^& popd ^& rd "%%~dpa"
|