Hi guys, I really need help to mass edit text files. More than 5000+ .txt need to edit. Here is description: 1) Put the filename inside txt files as the first line.
For example, my file name: Data-presentation-on-march-2012.txtCopy that filename and remove the “-”, and make it the first title of the body of my .txt file
So, it will become:
Data presentation on march 2012.The .txt contents data which is “bla bla bla bla”
So inside my .txt should become;Data presentation on march 2012
bla bla bla bla
*contain paragraph like that.
Don’t make it it Data presentation on march 2012. bla bla bla bla.
2) Please make it possible for me to add “?” at the end of the title. This is because some of .txt files contains How-To-Create-Bla-Bla.txtI put these type of .txt on other folder.
I need the script which works as first script above but I able to add “?” on every title because the filename does not contain “?”.
Or if it possible to include anything that start with "who, how, where, when, which" will automatically add "?"
3) Some of filename has many “-”. For example: Data-presentation-2012--Backup only.txt
Make sure the script will take “---” as “ .” , so it will become:
Data presentation 2012. Backup only.That’s all i need. I really appreciate your help. :) It will take months if I do all these manually. Thanks.

::This should deal with one and three @echo off
cd\
set filename=%1
set filename=%filename:c:\=%
set filename1=%filename%
set filename=%filename:-= %
set filename=%filename:backup=.backup%
set filename1=%filename1:c:\=%
echo %filename%>>temps.txt
type "%filename1%">>temps.txt
del %1
ren temps.txt %filename1%
pausetest everything twice :)
:: mike
Hi Mike, Thanks for your effort. But it seem not working for me. I save the file as .bat and I put the file on the folder. Then I run .bat file and nothing changed, cmd show errors.
How to use that code?
My apologize for my ignorance.
to test, click and drag one of the files onto the batch :: mike
I try using some text files, drag them to .bat. Got these errors: The system cannot find the file specified.
Error occurred while processing: zz\Mathematics.
The system cannot find the file specified.
Error occurred while processing: -History-And-Importance.txt.
The syntax of the command is incorrect.
Press any key to continue . . .
sorry try removing the cd\ :: mike
So, it will be; @echo off
set filename=%1
set filename=%filename:c:\=%
set filename1=%filename%
set filename=%filename:-= %
set filename=%filename:backup=.backup%
set filename1=%filename1:c:\=%
echo %filename%>>temps.txt
type "%filename1%">>temps.txt
del %1
ren temps.txt %filename1%
pauseStill not working. How do you make it works? Thanks Mike! I appreciate your effort to help me.
Its wierd, worked fine on mine. ok try adding this to the begining.
cd c:\folder\folder\
and modify the folder to be the working directory
:: mike
On my tests, the path interfered with the renaming operation:
ren temps.txt work\file-name.txt
You could subsitute "move" to fix this error, as written, OR,
since this needs to be a loop anyway, maybe use the drive-path-name features:@echo off
for /f "tokens=*" %%a in ('dir /b *.txt') do (
set filename=%%na
set filename1=%%nxa
call :title
)
goto :eof:title
set filename=%filename:-= %
set filename=%filename:backup=.backup%
echo %filename% > temps
copy temps+%filename1%
echo preparing to: move /y temps %filename1%
pause
move /y temps %filename1%
