|
Question : Remove underscore from begining of filenames?
|
|
I have a program that recovers deleted files, but it places an underscore character (_) before each file. I wish to use a DOS command batch file OR script to rename the files without the underscore.
There are several sub-directories deep, and some files don't have the underscore.
_file1.txt _file2.doc _file3.xls filewithout.txt
I've figured out the correct FOR cmd to find the files:
FOR /R %f IN (_*.*) DO REN %f *.*
but the REN command does not work.
I've tried: REN _*.* *.* REN _*.* ?*.* (they do not work)
Can anyone help?
|
|
Answer : Remove underscore from begining of filenames?
|
|
Sorry about the syntax error on the rename:
@echo off
for /R %%a in (_*.*) do call :PROCESS "%%a"
goto :EOF
:PROCESS
set FileName=%~n1
set FileName=%FileName:~1%
ren %1 "%FileName%%~x1"
|
|
|