0

Note: After asking this question, I found that the file browser Thunar, which comes with Xubuntu and is installable in any Ubuntu version, provides a bulk-renaming utility that works well for me.


I am trying to append timestamp hashes to files in directory or a userFileCode like a file password (for example all files of user have a prefix or suffix).

My problem is the mv command only works once so I cannot use wildcards like so

mv *.* *.*_dateHashsuffix

error says it's not a directory.

Seems like mv cannot handle multiple renames or do I have to use it like in cd /usr/bin && sudo mv test test_disabled && mv sudo sudo_disabled... in other words perhaps I have to pipe the ls > filelist.tst and then parse (do I use |grep here?) that separately in a .sh file script with executable permission run as so ./myscriptsname.sh or cant I use ls > directly in the script?

I see a use for this on my servers in the future to rename variables and files to prevent hacking. But a better idea altogether might be torrentDNS and zipSites in perhaps voxel based web browser with links to webpage content.

pomsky
  • 70,557
Punkroku
  • 1
  • 1
  • 5

1 Answers1

4

You can not use wildcards in the destination of the mv-command. What you think are wildcards is interpreted as the first three characters of the destinations name.

mv *.* *.*_something

will try to rename any file with a dot in its filename in the current directory to the name *.*_something. This will be successful for the first file the shell finds. The second attempt will fail because the file *.*_something already exists, thus you get an error saying that the destination is not a directory.

You have to go another way:

for num in *.*; do mv "${num}" "${num}_something"; done
mook765
  • 18,644