Thanks to all for very helpful responses. I have been trying to reinvent
the wheel, rename does the job nicely and the perl regex's are more
reliable. ^.*?-. allows removing the to the first - so repeated
applications remove to the track numbers. The comments regarding the
Trim_Line script were an education explaining why it did not work as
expected.
On 11/14/2017 11:07 AM, Thomas George wrote:
The problem is editing long file names to shorten them. An example
group of file names is attached.
The bash script copied from BashScripting is attached. This script
works perfectly with simple deletions, for example TrimLine.sh
"College" "" will remove College from each line in File.txt.
After experimenting with regular expressions with sed I found ls | sed
-e s/S.*-// reduced the file names in File.txt to just the names of
the Carols as shown in sed.txt. Used like this sed leaves the original
file unchanged.
Trim_Line.sh "S.*-" "" fails to actually change the file names.
Assuming Trim_Line.sh does not accept the regex as a pattern, I edited
it to replace the $1 in the sed command with the regex expression.
This does not work, the original file is left unchanged. I also
tried replacing $1 with ^.*- which also works with the test ls | sed
-e s/^.*-// but still the file names are unchanged.
I would appreciate any help or comments.
Tom George