How can I rename all files within a folder with the first word of their content? For example if a.txt contains “Unix is an OS” in its first line then a.txt should be renamed to Unix.txt
Renaming multiple files based on their contents
rename
rename
How can I rename all files within a folder with the first word of their content? For example if a.txt contains “Unix is an OS” in its first line then a.txt should be renamed to Unix.txt
Best Answer
Try this:
or more long variant (as script):
In case when destination file exists this one-liner skips it.