Skip to main content
added 2 characters in body
Source Link

Assuming that the filenames do not contain spaces, tabs or newlines, using one-liner and bash and awk would be simple:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }' | xargs -lL 1 mv

The xargs -l command execute mv for each line. Before executing command execute the following command and check that target and source file names are correct:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }'

should output something like:

melon.foo object001.foo
cookie.foo object002.foo
pie.foo object003.foo
apple.foo object004.foo

Assuming that the filenames do not contain spaces, tabs or newlines, using one-liner and bash and awk would be simple:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }' | xargs -l mv

The xargs -l command execute mv for each line. Before executing command execute the following command and check that target and source file names are correct:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }'

should output something like:

melon.foo object001.foo
cookie.foo object002.foo
pie.foo object003.foo
apple.foo object004.foo

Assuming that the filenames do not contain spaces, tabs or newlines, using one-liner and bash and awk would be simple:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }' | xargs -L 1 mv

The xargs -l command execute mv for each line. Before executing command execute the following command and check that target and source file names are correct:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }'

should output something like:

melon.foo object001.foo
cookie.foo object002.foo
pie.foo object003.foo
apple.foo object004.foo
Markup, and add assumptions about filenames.
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

UsingAssuming that the filenames do not contain spaces, tabs or newlines, using one-liner and bashbash and awkawk would be simple:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }' | xargs -l mv

The xargs -lxargs -l command execute mvmv for each line. Before executing command execute the following command and check that target and source file names are correct:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }'

should output something like:

melon.foo object001.foo
cookie.foo object002.foo
pie.foo object003.foo
apple.foo object004.foo

Using one-liner and bash and awk would be simple:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }' | xargs -l mv

The xargs -l command execute mv for each line. Before executing command execute the following command and check that target and source file names are correct:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }'

should output something like:

melon.foo object001.foo
cookie.foo object002.foo
pie.foo object003.foo
apple.foo object004.foo

Assuming that the filenames do not contain spaces, tabs or newlines, using one-liner and bash and awk would be simple:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }' | xargs -l mv

The xargs -l command execute mv for each line. Before executing command execute the following command and check that target and source file names are correct:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }'

should output something like:

melon.foo object001.foo
cookie.foo object002.foo
pie.foo object003.foo
apple.foo object004.foo
deleted 7 characters in body
Source Link

Using one-liner and bash and awk would be simple:

ls -rt | awk -F "." '{print  $1"."$2"$0 object"" object" sprintf("%03d",NR)   "." $2$NF }' | xargs -l mv

The xargs -l command execute mv for each line. Before executing command execute the following command and check that target and source file names are correct:

ls -rt | awk -F "." '{print  $1"."$2"$0 " object" sprintf("%03d",NR)  "." $2$NF }'

should output something like:

melon.foo object001.foo
cookie.foo object002.foo
pie.foo object003.foo
apple.foo object004.foo

Using one-liner and bash and awk would be simple:

ls -rt | awk -F "." '{print  $1"."$2" object"  sprintf("%03d",NR)   "." $2 }' | xargs -l mv

The xargs -l command execute mv for each line. Before executing command execute the following command and check that target and source file names are correct:

ls -rt | awk -F "." '{print  $1"."$2" object" sprintf("%03d",NR) "." $2 }'

should output something like:

melon.foo object001.foo
cookie.foo object002.foo
pie.foo object003.foo
apple.foo object004.foo

Using one-liner and bash and awk would be simple:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }' | xargs -l mv

The xargs -l command execute mv for each line. Before executing command execute the following command and check that target and source file names are correct:

ls -rt | awk -F "." '{print  $0 " object" sprintf("%03d",NR)  "." $NF }'

should output something like:

melon.foo object001.foo
cookie.foo object002.foo
pie.foo object003.foo
apple.foo object004.foo
deleted 2 characters in body
Source Link
Loading
Source Link
Loading