|
-
January 11th, 2002, 11:43 AM
#1
Batch rename
Hello there,
I have this directory full of "camera xxxx.htm" files. I need to rename them to be just xxxx.htm. There must be a simple way of doing it under cmd prompt. I have tried rename "camera *.htm" *.htm but of course it did not work. Anyone has any ideas? Using move could work as well. I just want to get rid of the lond file format so I can process those files in SQL server. For some reason SQL server does not like dealing with the long file names.
-
January 11th, 2002, 12:32 PM
#2
One way (test before using)...
rem rtest.bat
@echo off
setlocal
rem Split name and extension
for %%i in (*.*) do (
set name=%%~ni
set ext=%%~xi
call :RenFile
)
:RenFile
endlocal
rem Remove first 7 characters of name
set name-7="%name:~7%"
rem If filename is 7 characters or less skip rename
if %name-7%=="" goto :ERROR
rem If proposed new filename already exists skip the rename
if exist %name-7%"%ext%" goto :ERROR
rem Rename original
ren "%name%%ext%" %name-7%"%ext%"
:ERROR
-
January 11th, 2002, 01:23 PM
#3
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|