New answers tagged

-3 votes

Preserve directory structure when moving files using find

#!/bin/bash # '+' here shows that 'find' looking for files 45 and more days older from NOW # can be replaced with '-' (-45), to search for files with modification date from NOW to 45 days(max) days='+...
user avatar
  • 1
2 votes

Changing the name of a file based on a part of its original name that are between the first two instances of a character

Using the Perl-based rename utility, rename all files whose names match the pattern *interest*.txt. Each file is renamed by splitting the original name on the pipe symbols and then using the second ...
user avatar
  • 272k
1 vote

Changing the name of a file based on a part of its original name that are between the first two instances of a character

If you have perl-rename (called rename on many systems), you can do: $ rename -n 's/.*?\|(.+?)\|.*/$1.txt/' *txt >1234|interest1|randomstuff1.txt -> interest1.txt >5678|interest2|...
user avatar
  • 217k
1 vote

Changing the name of a file based on a part of its original name that are between the first two instances of a character

I've assumed that we're interested in files starting with >, containing (at least) two of your delimiter symbols (|) and ending with .txt: Example # Preparation touch '>1234|interest1|...
user avatar
  • 90.4k
1 vote
Accepted

Changing the name of a file based on a part of its original name that are between the first two instances of a character

This script assumes that you want to process all files that contain at least two | characters and end with .txt. The example file names in the question would also match *interest*.txt. If your ...
user avatar
  • 5,433
0 votes

Rename 2 similar files with different extension to first file, but keep extensions

In zsh: for f (???.srt) () { (( $# == 1 )) && mv -- $f $1:r.srt } $f[1,3]?*.m4v(NY2) Which renames the ???.srt file, copying the root name of the m4v file with the same 3 character prefix ...
user avatar
0 votes
Accepted

Rename 2 similar files with different extension to first file, but keep extensions

Given one of the .m4v names in the shell variable name, the name of the corresponding .srt file is had by trimming $name at the first space and adding the .srt filename suffix. This is done with ${...
user avatar
  • 272k
0 votes

How replace all dots AFTER other chars got captured

Just as with a sed or perl script, you can have more than one statement (either separated by ;, or by using multiple -e options) in a perl rename script. For example: $ touch 'my.series.name.S01E'{01....
user avatar
  • 68.7k

Top 50 recent answers are included