I have a bunch of files that I'd like to rename. Their filenames are in a certain format:
p1.uniquenameA#blah_a
p2.uniquenameB#blah_b
p3.uniquenameC#blah_c
p4.uniquenameD#blah_d
p5.uniquenameE#blah_e
p6.uniquenameF#blah_f
p7.uniquenameG#blah_g
p8.uniquenameH#blah_h
p9.uniquenameI#blah_i
p10.uniquenameJ#blah_j
There's a prefix before each unique file name. In this case, that prefix starts with the letter p
and has a number after the p
that increments by one. A period (.
) separates the prefix from the unique file name. There's a suffix after each unique file name that begins with a hashtag (#
). I'd like to remove the prefixes up to and including the periods and I'd also like to remove the suffixes beginning at and including the hashtags. I'd like the resulting filenames to be only the unique file names between the periods and the hash tags like this:
uniquenameA
uniquenameB
uniquenameC
uniquenameD
uniquenameE
uniquenameF
uniquenameG
uniquenameH
uniquenameI
uniquenameJ
I'm new to scripting, so if you could explain how the code works in addition to supplying the code, I'd greatly appreciate it.