ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > PublicDomainVic

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

(1/3) > >>

nkormanik:
Vic (and community), I used to put small requests in Skwire's section.  Haven't for a while.  I have a mini request presently that probably belongs over there.  But will just put it here for now....

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

BGM:
Well, what if you just copied the file and changed the extension to ".bak" or something?  Then, when you want it back, just change the extension back from bak.

Or, you could log what files you open. 

What is a case scenario where you would want to only temporarily name something and keep ahold of the old name?

publicdomain:
Change File Name.  Then change it back to what it was.
-nkormanik (February 25, 2022, 04:47 PM)
--- End quote ---

Hi Nick, I'm in with nkNameFlip @ https://github.com/publicdomain/nknameflip

As to the section, if you post it here rest assured there's no problem on my side.

Hey! GitHub motto says it: current goal is 52+ releases per year, so I'm glad to do it :) Your creative ideas do help others around :Thmbsup: Thanks for following your passion & publishing them.


Regarding naming:

Is the format "number - filename.ext" all the time?

Do you need a split by hyphen or any other character as an option?

Feel free to elaborate on the naming format.

Cheers!

nkormanik:
@BGM , @publicdomain and helpful community.

BGM, your idea is a good one.  Copy out, then copy back in.  Or rename.  Etc.

Trouble is, the file contents will change.

Here is the actual scenario:

I have 100 SAS datasets.  Each dataset is alone in its folder.  The folder name corresponds to the dataset filename, plus some extra:

Below are the first three folders, and the sole file inside:


--- ---===========
E:\00\AAPL\
===========
aapl_combined.sas7bdat

===========
E:\00\ACWI\
===========
acwi_combined.sas7bdat

===========
E:\00\ACWX\
===========
acwx_combined.sas7bdat

I need to update -- add some additional columns -- to each and every dataset file.

The 'program' -- or more accurately, 'script' -- I am going to use to make the changes to each file expects the name of the file to be:

combined.sas7bdat

No prefix.

And the location of said file is set to be:

C:\SAS_1\

So, it appears that I'll have to use one of the two following approaches:

(first dragging each respective file one at a time to the 'work' folder for the running of the script)

1.  Change the 'script' file 100 times, to tailor for the specific prefix.

or

2.  Change the name of each file, temporarily.  x100.

Going #2 route, I was thinking of TEMPORARILY changing the filename:

aapl_combined.sas7bdat --> combined.sas7bdat

Then making changes to the dataset file with the existing script.

Then changing the filename back to what it was before:

combined.sas7bdat --> aapl_combined.sas7bdat

Then dragging the changed dataset file back to its proper, home folder.

This whole rigmarole is likely faced regularly by programmers.  There surely are ways and means of conducting things more efficiently.  If anyone wants to chime in their thoughts regarding a more orderly process, please speak up.

Thanks much!

Nicholas Kormanik

Ath:
Just a suggestion, but wouldn't it be much more efficient to improve the 'script' to handle any filename? This workaround seems so inefficient, and prone to bite you in the behind, sometime soon.

Navigation

[0] Message Index

[#] Next page

Go to full version