• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Renaming software with txt script

Joined
Sep 18, 2017
Messages
54 (0.02/day)
System Name The Berserker Armor
Processor Ryzen 7 7700x
Motherboard Asus TUF Gaming X670E Plus Wifi
Cooling CORSAIR ICUE H150i RGB ELITE
Memory Corsair Vengeance DDR5 2x16GB 6000mhz
Video Card(s) ASUS TUF Gaming RTX 4070 Ti
Storage Samsung 980 Pro 1tb, Samsung 980 1tb
Display(s) LG 27GL850-B 144hz
Case Corsair 5000D Airflow Black + 3x SP120 fans
Power Supply Seasonic Focus Gold GX-850
Mouse Corsair Harpoon Rgb Pro
Keyboard Corsair K60 Rgb Pro
Software Windows 11 Pro
I have 2000 folders with the data inside, inside each folder there is a text file contain the main info like name, year, city, etc.
So I was wondering, I would like to rename those 2000 folders based on the txt inside to [year]-city-name to make my work easier. The original folder names are just sequential number 3101 and so on
Can anyone help me with it?
 
Joined
Aug 26, 2019
Messages
558 (0.33/day)
This may not be the hand holding you're looking for, but here's a quick example in Bash of how you can take a match and apply it to a name. What I'm doing here is taking .flac files on my NAS (that's my pwd when running the below) and transcoding them to mp3 onto my mp3 player.

for file in *.flac; do flac -cd "$file" | lame -q 0 -V0 - "/media/Cowan/Music/An Awesome CD/${file%.flac}.mp3"; done
 

W1zzard

Administrator
Staff member
Joined
May 14, 2004
Messages
27,049 (3.71/day)
Processor Ryzen 7 5700X
Memory 48 GB
Video Card(s) RTX 4080
Storage 2x HDD RAID 1, 3x M.2 NVMe
Display(s) 30" 2560x1600 + 19" 1280x1024
Software Windows 10 64-bit
I suspect OP is on Windows, so probably doesn't have access to bash
 
Joined
Sep 18, 2017
Messages
54 (0.02/day)
System Name The Berserker Armor
Processor Ryzen 7 7700x
Motherboard Asus TUF Gaming X670E Plus Wifi
Cooling CORSAIR ICUE H150i RGB ELITE
Memory Corsair Vengeance DDR5 2x16GB 6000mhz
Video Card(s) ASUS TUF Gaming RTX 4070 Ti
Storage Samsung 980 Pro 1tb, Samsung 980 1tb
Display(s) LG 27GL850-B 144hz
Case Corsair 5000D Airflow Black + 3x SP120 fans
Power Supply Seasonic Focus Gold GX-850
Mouse Corsair Harpoon Rgb Pro
Keyboard Corsair K60 Rgb Pro
Software Windows 11 Pro
NVM guys. I did them manually with my fingers. My left pinky and index fingers were sore with that thousands CTRL C+V.
Told the survey guys to rename the folders like that so I don't have to do this anymore with the next batch.
 

Aiden_

New Member
Joined
Feb 4, 2021
Messages
13 (0.01/day)
Definitely too late now, but if this happens again, maybe try a Python script - would probably take 10-15 mins to get something working and then minutes for it to get the job done.
 
Last edited by a moderator:
Joined
Aug 26, 2019
Messages
558 (0.33/day)
@remunramu I'm not sure where you're at in your career or if you're even in the IT world, but it would be worth investing even a modicum of time into python/powershell/bash/whatever. Not giving you grief, and as posted above also not willing to code for you, but hopefully this is positive peer pressure to somewhat familiarize yourself with a bit of scripting. :)
 
Top