1.

Solve : Change File Name??

Answer»

Help:


<<"I have 100 files that are named 001xxx, 002xxx, 003xxx, and so on with the "xxx" standing for the remainder of the file name. Each name being different after the numbering.

I would like to know if there is a way to globally change the files name, taking off the numbering and leaving the remainder of the name intact.">>I use this: http://www.bulkrenameutility.co.uk/Main_Intro.phpAssuming that

1. In each case, you wish to remove the first 3 characters of each filename
2. All the files to be renamed are in the same folder
3. There are not any other files in the same folder that should not be renamed.

Code: [Select]
@echo off
setlocal enabledelayedexpansion
set batchname=%~nx0
for /f "delims=" %%F in ( ' dir /B ^| find /v "%batchname%" ' ) do (
set oldname=%%F
set newname=!oldname:~3!
echo renaming "!oldname!" to "!newname!"
REM ren "!oldname!" "!newname!"
)
echo Done
echo.
echo pause


Put a copy of this batch in the folder with the files to be renamed; it will not rename itself; test it and use Notepad to remove the REM when you are HAPPY it works; test it with a copy of your data to be safest.


Quote from: Salmon Trout on August 20, 2009, 01:03:15 AM

Assuming that

1. In each case, you wish to remove the first 3 characters of each filename
2. All the files to be renamed are in the same folder
3. There are not any other files in the same folder that should not be renamed.

Code: [Select]
@echo off
setlocal enabledelayedexpansion
set batchname=%~nx0
for /f "delims=" %%F in ( ' dir /b ^| find /v "%batchname%" ' ) do (
set oldname=%%F
set newname=!oldname:~3!
echo renaming "!oldname!" to "!newname!"
REM ren "!oldname!" "!newname!"
)
echo Done
echo.
echo pause


Put a copy of this batch in the folder with the files to be renamed; it will not rename itself; test it and use Notepad to remove the REM when you are happy it works; test it with a copy of your data to be safest.



i was looking for a batchfile to do that
it works great
and i am not the ORIG poster
it makes no sense to me
how does it work?
how do you MAKE it take of 5 chars?
Quote from: smeezekitty on August 20, 2009, 01:35:20 AM
how do you make it take of 5 chars?

Code: [Select]set newname=!oldname:~N!
Replace N in that line with the number of characters to remove from the beginning of the filename.

works perfectly


Discussion

No Comment Found