Skip to main content
Tidying up
Source Link
Greenonline
  • 2.1k
  • 7
  • 23
  • 32

This command would seem to do what you wish

for file in *.* ; do cp $file ${file//a\./b\.} ; done

Adapted from this answer to Renaming part of a filename

Actually, you could just do:

for file in * ; do cp $file ${file//a\./b\.} ; done

Note that the . has to be escaped using \.. This is primarily because your example is a filename of a single letter, which could potentially conflict with a letter in the extension.

If your filenames are a bit more explicit, such as doggy.txt, doggy.pdf, doggy.xls, etc., and you want to change them to feline.txt, feline.pdf, ..., etc., then you could do away with escaping the . (and the . all together), like so:

for file in *.* ; do cp $file ${file//doggy/feline} ; done

Note that the commands above will create a copy of the files, i.e.:

% ls
a.pdf   a.txt   a.xls   b.pdf   b.txt   b.xls

If you wish to just rename them, then use mv instead:

for file in * ; do mv $file ${file//a\./b\.} ; done

or

for file in *.* ; do mv $file ${file//doggy/feline} ; done

This command would seem to do what you wish

for file in *.* ; do cp $file ${file//a\./b\.} ; done

Adapted from this answer to Renaming part of a filename

Actually, you could just do

for file in * ; do cp $file ${file//a\./b\.} ; done

Note that the . has to be escaped using \.. This is primarily because your example is a filename of a single letter, which could potentially conflict with a letter in the extension.

If your filenames are a bit more explicit, such as doggy.txt, doggy.pdf, doggy.xls, etc., and you want to change them to feline.txt, feline.pdf, ..., etc., then you could do away with escaping the . (and the . all together), like so:

for file in *.* ; do cp $file ${file//doggy/feline} ; done

Note the commands above will create a copy of the files, i.e.:

% ls
a.pdf   a.txt   a.xls   b.pdf   b.txt   b.xls

If you wish to just rename them, then use mv instead:

for file in * ; do mv $file ${file//a\./b\.} ; done

or

for file in *.* ; do mv $file ${file//doggy/feline} ; done

This command would seem to do what you wish

for file in *.* ; do cp $file ${file//a\./b\.} ; done

Adapted from this answer to Renaming part of a filename

Actually, you could just do:

for file in * ; do cp $file ${file//a\./b\.} ; done

Note that the . has to be escaped using \.. This is primarily because your example is a filename of a single letter, which could potentially conflict with a letter in the extension.

If your filenames are a bit more explicit, such as doggy.txt, doggy.pdf, doggy.xls, etc., and you want to change them to feline.txt, feline.pdf, ..., etc., then you could do away with escaping the . (and the . all together), like so:

for file in * ; do cp $file ${file//doggy/feline} ; done

Note that the commands above will create a copy of the files, i.e.:

% ls
a.pdf   a.txt   a.xls   b.pdf   b.txt   b.xls

If you wish to just rename them, then use mv instead:

for file in * ; do mv $file ${file//a\./b\.} ; done

or

for file in * ; do mv $file ${file//doggy/feline} ; done
Rename or copy?
Source Link
Greenonline
  • 2.1k
  • 7
  • 23
  • 32

This command would seem to do what you wish

for file in *.* ; do cp $file ${file//a\./b\.} ; done

Adapted from this answer to Renaming part of a filename

Actually, you could just do

for file in * ; do cp $file ${file//a\./b\.} ; done

Note that the . has to be escaped using \.. This is primarily because your example is a filename of a single letter, which could potentially conflict with a letter in the extension.

If your filenames are a bit more explicit, such as doggy.txt, doggy.pdf, doggy.xls, etc., and you want to change them to feline.txt, feline.pdf, ..., etc., then you could do away with escaping the . (and the . all together), like so:

for file in *.* ; do cp $file ${file//doggy/feline} ; done

Note the commands above will create a copy of the files, i.e.:

% ls
a.pdf   a.txt   a.xls   b.pdf   b.txt   b.xls

If you wish to just rename them, then use mv instead:

for file in * ; do mv $file ${file//a\./b\.} ; done

or

for file in *.* ; do mv $file ${file//doggy/feline} ; done

This command would seem to do what you wish

for file in *.* ; do cp $file ${file//a\./b\.} ; done

Adapted from this answer to Renaming part of a filename

Actually, you could just do

for file in * ; do cp $file ${file//a\./b\.} ; done

Note that the . has to be escaped using \.. This is primarily because your example is a filename of a single letter, which could potentially conflict with a letter in the extension.

If your filenames are a bit more explicit, such as doggy.txt, doggy.pdf, doggy.xls, etc., and you want to change them to feline.txt, feline.pdf, ..., etc., then you could do away with escaping the . (and the . all together), like so:

for file in *.* ; do cp $file ${file//doggy/feline} ; done

This command would seem to do what you wish

for file in *.* ; do cp $file ${file//a\./b\.} ; done

Adapted from this answer to Renaming part of a filename

Actually, you could just do

for file in * ; do cp $file ${file//a\./b\.} ; done

Note that the . has to be escaped using \.. This is primarily because your example is a filename of a single letter, which could potentially conflict with a letter in the extension.

If your filenames are a bit more explicit, such as doggy.txt, doggy.pdf, doggy.xls, etc., and you want to change them to feline.txt, feline.pdf, ..., etc., then you could do away with escaping the . (and the . all together), like so:

for file in *.* ; do cp $file ${file//doggy/feline} ; done

Note the commands above will create a copy of the files, i.e.:

% ls
a.pdf   a.txt   a.xls   b.pdf   b.txt   b.xls

If you wish to just rename them, then use mv instead:

for file in * ; do mv $file ${file//a\./b\.} ; done

or

for file in *.* ; do mv $file ${file//doggy/feline} ; done
Expanded answer
Source Link
Greenonline
  • 2.1k
  • 7
  • 23
  • 32

This command would seem to do what you wish

for file in *.* ; do cp $file ${file//a\./b\.} ; done

Adapted from this answer to Renaming part of a filename

Actually, you could just do

for file in * ; do cp $file ${file//a\./b\.} ; done

Note that the . has to be escaped using \.. This is primarily because your example is a filename of a single letter, which couldcould potentially conflict with a letter in the extension.

If your filenames are a bit more explicit, such as doggy.txt, doggy.pdf, doggy.xls, etc., and you want to change them to feline.txt, feline.pdf, ..., etc., then you could do away with escaping the . (and the . all together), like so:

for file in *.* ; do cp $file ${file//doggy/feline} ; done

This command would seem to do what you wish

for file in *.* ; do cp $file ${file//a\./b\.} ; done

Adapted from this answer to Renaming part of a filename

Actually, you could just do

for file in * ; do cp $file ${file//a\./b\.} ; done

Note that the . has to be escaped using \.. This is primarily because your example is a filename of a single letter, which could conflict with a letter in the extension.

If your filenames are a bit more explicit, such as doggy.txt, doggy.pdf, doggy.xls, etc., and you want to change them to feline.txt, etc., then you could do away with escaping the ., like so:

for file in *.* ; do cp $file ${file//doggy/feline} ; done

This command would seem to do what you wish

for file in *.* ; do cp $file ${file//a\./b\.} ; done

Adapted from this answer to Renaming part of a filename

Actually, you could just do

for file in * ; do cp $file ${file//a\./b\.} ; done

Note that the . has to be escaped using \.. This is primarily because your example is a filename of a single letter, which could potentially conflict with a letter in the extension.

If your filenames are a bit more explicit, such as doggy.txt, doggy.pdf, doggy.xls, etc., and you want to change them to feline.txt, feline.pdf, ..., etc., then you could do away with escaping the . (and the . all together), like so:

for file in *.* ; do cp $file ${file//doggy/feline} ; done
added 454 characters in body
Source Link
Greenonline
  • 2.1k
  • 7
  • 23
  • 32
Loading
Source Link
Greenonline
  • 2.1k
  • 7
  • 23
  • 32
Loading