Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
filename character removal batch
Name: flateric Date: December 27, 2008 at 14:46:06 Pacific OS: Windows XP CPU/Ram: 3000mhz 1gb Product: Dell / 9150
Comment:
what command can i use to remove the first 15 chars of hundereds of files so i can get them in alphabetical order, files are named CBEP???-?-?? - filename.xxx, the ? are different for every file (numbers) i want to remove everything apart from filename.xxx. cheers, Royce
Name: reno Date: December 28, 2008 at 02:31:09 Pacific
Reply:
@echo off setLocal EnableDelayedExpansion
set okToRename=n :loop for /f "tokens=* delims= " %%f in ('dir /b /a-d CBEP*.*') do ( set filename=%%f if !okToRename!==y (ren %%f !filename:~15!) else (echo %%f==^>!filename:~15!) ) set /P okToRename="Is It OK to Rename Those File(s) (y/n)?" if !okToRename!==y goto :loop
0
Response Number 2
Name: A2Z Date: December 28, 2008 at 12:55:10 Pacific
Reply:
The original post seems to include spaces in the 13th and 15th positions in the filenames, and spaces may be present in the path to the files. Would it not be wise to enclose the path/filenames in " "?
0
Response Number 3
Name: Mechanix2Go Date: December 29, 2008 at 05:07:14 Pacific
Reply:
@echo off & setLocal EnableDelayedExpansion
pushd c:\files
for /f "tokens=* delims= " %%a in ('dir/b/a-d') do ( set FN=%%a set FN=!FN:~15,77! ren "%%a" "!FN!" )
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 4
Name: reno Date: December 29, 2008 at 05:56:18 Pacific
Reply:
dang, didnt thought of the space. hope i havent cause any damage in the renaming process.
those batch scripting is still new stuff to me, i will be more careful in the future.
Summary: Is it possible to echo the ">" and "<" character in batch so the user can see it? If you give up, might as well give up everything in life....
Summary: for things like this, don't use batch. Even if it can be done, it would be like what you posted. use a tool especially designed for the job of text processing. here's a vbscript that uses regular expr...
Summary: Extended characters are a bit of a problem in batch. There are two main ways to achieve what you want to do, either change the code page or find the character that is used for your characters alias. C...