1.

Solve : Elementary file rename problem.?

Answer»

First the obvious: I don't know much about batch files.

I have searched long and hard for my own solution before imposing here, but have not been able to locate a solution.

I'm trying to create a simple routine to rename all of the files on a CDROM (or directory) by prepending a number to the beginning of each of the original file names.

example:
ASSUMING the number = 100
original file name = ORIGFILENAME.txt
rewritten file name = 100ORIGFILENAME.txt

Code: [SELECT]set n=100
echo %n%
xcopy e:\*.* D:\casephotos\%n%*.*

The code above produces the result below, which I have achieved by many different METHODS, which overwrites the first portion of the original file name with the text to be prepended instead of adding the text to the beginning.

original file name = ORIGFILENAME.txt
rewritten file name = 100GFILENAME.txt

Thanks in advance for your time.

rI found a solution in the forum, NAMELY:

for /f "tokens=1* delims=." %%i in ('dir /b /a-d') do (
if "%%j" NEQ "bat" move ".\%%i.%%j" ".\55%%i55.%%j" )

Thanks for /f "delims==" %%F in ('dir /s /b /a-d') do (
ren %%~dpnxF 100%%~dpnxF
)



Discussion

No Comment Found