On Thu, 12 Jan 2023 at 18:49, Piers Rowan via luv-main <[email protected]> wrote:
> I have a structure like: > > /Dir1/123.junk.doc > /Dir1/456.junk.pdf > /Dir1/SubDir/1123.junk.doc > /Dir1/SubDir/1456.junk.pdf > /Dir2/SubDir/4321.junk.doc > /Dir2/SubDir/7676.junk.pdf > ...etc... > > I want some guidance as to how to make: > > 1123.junk.doc > 1123.doc > > $ID.junk.$EXT > $ID.$EXT Hi, guidance as requested: I assume you're seeking a commandline solution, not a GUI one. 1) Write a shell script that recurses into all subdirectories, finds matching filenames, 'mv' to new name. Bash shell provides all the tools necessary. Some ideas here: http://mywiki.wooledge.org/BashFAQ/030 Could be done with a recursive function. Or, there's probably some shorter approach if using the enhanced globbing features. 2) Or, search the web for such a script. 3) Or, use 'find' to detect all subdirectors and in each one invoke the 'rename' commandline tool, which takes Perl 'substitute' command argument and applies that to matching filenames. See: https://manpages.debian.org/bullseye/rename/rename.1.en.html 4) There's probably examples of doing that on the web too, findable with appropriate keywords. 5) Search a site like this: https://superuser.com/search?q=linux+recursive+rename _______________________________________________ luv-main mailing list -- [email protected] To unsubscribe send an email to [email protected]
