You are not logged in.
In a batch file, I am trying to remove a static set of characters from all files in a bunch of sub-directories. I'd prefer to run the batch file on a set of files on a Win2000 box.
sample filename: a_file_this.txt
Objective: get the "a_file" part in a variable for later processing.
where are files in many sub-directories are 8 characters long or less not including the "_this" part.
where every file has same exact "_this" part.
where some files have the first underscore, others do not. No more than one underscore not counting the "_this" part.
Either rename the entire file or get the "a_file" part into a variable.
My problem is the use of two underscores in the original filename prevents me from using DELIMS to target either the "a_file" or "_this" part.
thanks !
Offline
I would read the entire filename into a variable and then manipulate it in memory
SET _filename=a_file_this.txt
SET _result=%_filename:_this=%
That should remove '_this' from the variable and return "a_file.txt" part into %_result%
This assumes you don't have any files named like '_this_file_this.txt'
for more see https://ss64.com/nt/syntax-replace.html
Offline
Perfect, thank you. Appreciate the additional resource.
Offline