Batch help to modify a text file and make copy b4 modifying

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
val5662
Posts: 34
Joined: 18 Dec 2013 09:48

Batch help to modify a text file and make copy b4 modifying

#1 Post by val5662 » 18 Dec 2013 10:04

Hi Guys... :D
I need the following batch file code modified so the original file is copied and renamed to "copy-original.txt" before modifying the original.
The batch file sorts out text file contents alphabetically , a at top , z at bottom.
The way it is now it leaves the original untouched and unnamed and makes a sorted alphabetically copy of original and is renamed.

@echo off
sort original.txt /o modified-original.txt
echo: FILE HAS BEEN SORTED ALPHABETICALLY TO AN OUTPUT FILE
echo: THE ORIGINAL HAS BEEN LEFT ALONE
pause

Thanks!
I appreciate your help.
Val

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Batch help to modify a text file and make copy b4 modify

#2 Post by Squashman » 18 Dec 2013 10:08

ren original.txt copy-original.txt

val5662
Posts: 34
Joined: 18 Dec 2013 09:48

Re: Batch help to modify a text file and make copy b4 modify

#3 Post by val5662 » 18 Dec 2013 11:00

Squashman....
I am guessing you meant to do it this way:

@echo off
ren original.txt copy-original.txt
sort copy-original.txt /o original.txt
pause

Anyway,it worked great.....Thanks a bunch!

Val

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Batch help to modify a text file and make copy b4 modify

#4 Post by Squashman » 18 Dec 2013 12:43

Not really.
sort original.txt /o modified-original.txt
rename original.txt copy-original.txt

val5662
Posts: 34
Joined: 18 Dec 2013 09:48

Re: Batch help to modify a text file and make copy b4 modify

#5 Post by val5662 » 18 Dec 2013 13:16

Squashman....
Ok....Thanks again!
Val

Post Reply