Small Side Request

2 views
Skip to first unread message

nkor...@gmail.com

unread,
Feb 25, 2022, 5:55:45 PM2/25/22
to sem...@googlegroups.com

 

Please forgive me for posting a question outside of TSE's direct area.

 

But not sure where else to ask.  (Suggest a forum if you know of one?)

 

The present mini-challenge is:

 

Change File Name.  Then change it back to what it was.

 

This would be a two-phase process:

 

A file is in a folder.  Alone.  File is:  "4863 - xyz.txt"

 

Step #1.  Change that file's name to:  "xyz.txt"

 

(User now does some things.  Blah, blah....)

 

Step #2.  Change the file "xyz.txt" back to its original name, "4863 - xyz.txt"

 

Done!

 

If there is another forum where this request is more appropriate, please let me know.  Or if there is a means that I ought to have access to (some programming language?).

 

Thanks a million.  Hope all are well.

 

Nicholas Kormanik

 

 

knud van eeden

unread,
Feb 26, 2022, 11:44:16 AM2/26/22
to sem...@googlegroups.com
This is certainly inside tasks that can be done using TSE.

Something like this:


Steps:

1. Collect all filenames of interest

1.1 e.g. load from disk

-a -s <your file path> 

E.g.

-a -s c:\temp\*.txt

could load all filenames of a directory and its sub directories into the TSE ring

2. Get all full filenames currently in the TSE ring into a file or buffer

E.g.

c:\temp\xyz - foobar01.txt
c:\temp\xyz - foobar02.txt
c:\temp\xyz - foobar03.txt

3. Optionally edit or add to these collected full filenames of interest

E.g.

c:\temp\xyz - foobar01a.txt
c:\temp\xyz - foobar02b.txt
c:\temp\xyz - foobar03c.txt

4. Store the result in a file 1 to have a history and being able to backup if necessary

SaveAs( "c:\temp\foobarOLD.txt" )

5. Filter the remaining filenames, e.g. doing a global search/replace in the filenames (e.g. using a regular expression) removing the '... -' in front.

E.g.

c:\temp\foobar01a.txt
c:\temp\foobar02b.txt
c:\temp\foobar03c.txt

6. Then make 2 columns with the old filenames in double quotes and the new filenames in double quotes and store these in a .bat file, put 'ren' in front of each of the lines and save.

E.g. SaveAs( "c:\temp\foobarRENAME.bat" )

ren "c:\temp\xyz - foobar01a.txt" "c:\temp\foobar01a.txt"
ren "c:\temp\xyz - foobar02b.txt" "c:\temp\foobar02a.txt"
ren "c:\temp\xyz - foobar03c.txt" "c:\temp\foobar03a.txt"

7. Then run the .bat file that will rename all the old filenames to the new filenames.

Run "c:\temp\foobarRENAME.bat"

8. Optionally create a new .bat file to rename back to new filenames to the old filenames.

E.g. SaveAs( "c:\temp\foobarRENAME_BACK.bat" )

ren "c:\temp\foobar01a.txt" "c:\temp\xyz - foobar01a.txt" 
ren "c:\temp\foobar02a.txt" "c:\temp\xyz - foobar02b.txt"
ren "c:\temp\foobar03a.txt" "c:\temp\xyz - foobar03c.txt" 

then 

Run "c:\temp\foobarRENAME_BACK.bat"

with friendly greetings
Knud van Eeden



--

---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/semware/046901d82a9a%24d139b5a0%2473ad20e0%24%40gmail.com.

nkor...@gmail.com

unread,
Feb 26, 2022, 6:13:29 PM2/26/22
to sem...@googlegroups.com

 

What a TSE Wizard you are, Knud!  Thanks so much....

Reply all
Reply to author
Forward
0 new messages