On Tuesday, November 14, 2017 at 9:50:06 PM UTC+5:30, 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.
For such work I find emacs dired useful [dired is emacs' file editor] For more convenience add: 1. Menu → Immediate → Edit File names (shortcut Ctrl-x Ctrl-q) combined with 2. column-editing mode of cua https://vimeo.com/1168225