I have a directory with a bunch of text files with only the file names ( no extension ) . I need to add a .txt extension to every file . what is the best way to do this ?
I have a directory with a bunch of text files with only the file names ( no extension ) . I need to add a .txt extension to every file . what is the best way to do this ?
if it ain't broke you haven't tweaked it enough
Assuming all the files in the directory have no extension and all the files want one
In the directory that contains the files
If you mean only some of the files then you will need the test ( [[ ) command first.Code:for f in *; do mv "$f" "$f".txt; done
that did it . Thank You
if it ain't broke you haven't tweaked it enough
EDIT: D'oh! nothingspecial beat me to it!
If you are looking for a GUI tool, then check out:
- thunar (file manager)
- gprename
- gnome-commander (file manager)
- purrr
- pyrenamer
- gwenrename
- krename
In the CLI there are many ways. On Debian and Ubuntu I'd probably use the Perl based rename command.
-n tells to prename to only print the file names which would have been renamed.Code:cd path/to/dir/where/the/files/are prename -n 's/(.*)/$1.txt/' ./*
But you can use the rename command from the util-linux package, mmv or you can write your own little script.
Bookmarks