How can I batch rename text files to be the first word in each text file?
1
vote
2
answers
1198
views
I need to rename a few thousand text files to be the first word in the text file plus the file extension (.txt) using the terminal. All the files are in a single directory, and are currently named int the pattern "xx0001.txt' through 'xx9999.txt'.
The first word in each file is of this pattern: '##221251', so maybe my issue comes from needing to comment out the pound signs.
I've tried:
rename File.ReadAllText('*.txt').split(' ')
Which throws the error:
zsh: no matches found: File.ReadAllText(*.txt).split( )
Thanks in advance for your help. I'm a true novice.
Asked by mqh5962
(13 rep)
Apr 24, 2020, 05:43 PM
Last activity: Apr 24, 2020, 07:34 PM
Last activity: Apr 24, 2020, 07:34 PM