Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
3
votes
2
answers
241
views
How can 'rename' be used to rename file in a specific directory?
I need to rename a part of a Java JAR file and I need to keep the version numbers in the filename: Original file: hello-service-0.1.0.jar Expected file: hello-my-service-0.1.0.jar The following command does the job properly, but I need to be in the directory where the file sits, so I need to change-...
I need to rename a part of a Java JAR file and I need to keep the version numbers in the filename:
Original file: hello-service-0.1.0.jar
Expected file: hello-my-service-0.1.0.jar
The following command does the job properly, but I need to be in the directory where the file sits, so I need to change-directory before run the
rename
command:
cd "$dir"
rename --verbose "s/hello-service/hello-my-service/" *.jar
cd -
But as I run the rename
from a bash script, I would like to avoid the boilerplate code that change directory before and after the rename
command.
**I have something like this:**
dir="/home/me/projects/hello/jar"
actual="hello-service"
expected="hello-my-service"
rename --verbose "s/$actual/$expected/" *.jar
How to specify the directory name for the rename
command?
zappee
(323 rep)
Jul 12, 2025, 12:09 AM
• Last activity: Jul 13, 2025, 01:06 PM
466
votes
19
answers
707787
views
How do I change the extension of multiple files?
I would like to change a file extension from `*.txt` to `*.text`. I tried using the [`basename`](https://man7.org/linux/man-pages/man1/basename.1.html) command, but I'm having trouble changing more than one file. Here's my code: files=`ls -1 *.txt` for x in $files do mv $x "`basename $files .txt`.te...
I would like to change a file extension from
*.txt
to *.text
. I tried using the [basename
](https://man7.org/linux/man-pages/man1/basename.1.html) command, but I'm having trouble changing more than one file.
Here's my code:
files=ls -1 *.txt
for x in $files
do
mv $x "basename $files .txt
.text"
done
I'm getting this error:
>basename: too many arguments Try basename --help' for more information
afbr1201
(4989 rep)
Aug 29, 2011, 06:33 AM
• Last activity: Jul 11, 2025, 06:10 PM
1
votes
0
answers
51
views
rename "Duplicate specification" for option error
The other day something started going wrong with the perl `rename` terminal command that was pre-installed on my system; which is Ubuntu 22.04.5 LTS. When I try to use any version of the rename command I get the following message: Duplicate specification "V|version" for option "v" Duplicate specific...
The other day something started going wrong with the perl
rename
terminal command that was pre-installed on my system; which is Ubuntu 22.04.5 LTS. When I try to use any version of the rename command I get the following message:
Duplicate specification "V|version" for option "v"
Duplicate specification "E=s" for option "e"
By this I mean that any attempts at using rename, including simply rename -h
bring up this error. rename -h
will still print out the help information, which is as follows for my version of rename (2.02)
Duplicate specification "V|version" for option "v"
Duplicate specification "E=s" for option "e"
Usage:
rename [ -h|-m|-V ] [ -v ] [ -0 ] [ -n ] [ -f ] [ -d ] [ -u [enc]]
[ -e|-E perlexpr]*|perlexpr [ files ]
Options:
-v, --verbose
Verbose: print names of files successfully renamed.
-0, --null
Use \0 as record separator when reading from STDIN.
-n, --nono
No action: print names of files to be renamed, but don't rename.
-f, --force
Over write: allow existing files to be over-written.
--path, --fullpath
Rename full path: including any directory component. DEFAULT
-d, --filename, --nopath, --nofullpath
Do not rename directory: only rename filename component of path.
-h, --help
Help: print SYNOPSIS and OPTIONS.
-m, --man
Manual: print manual page.
-V, --version
Version: show version number.
-u, --unicode [encoding]
Treat filenames as perl (unicode) strings when running the
user-supplied code.
Decode/encode filenames using encoding, if present.
encoding is optional: if omitted, the next argument should be an
option starting with '-', for instance -e.
-e Expression: code to act on files name.
May be repeated to build up code (like "perl -e"). If no -e, the
first argument is used as code.
-E Statement: code to act on files name, as -e but terminated by
';'.
If I attempt any actuall usage of the program, even as simple as rename -n -s/\.txt//' *
the program stalls out and freezes after printing the error message.
As far as I have been able to find digging around for help and answers, the issue is apparently due to Getopt::Long
somehow ignoring case, despite the fact that File::Rename::Options
is meant to specifically turn on no_ignore_case
when it calls Getopt::Long
.
I have tried updating, upgrading, and cleaning apt
and apt-get
, purging and then reinstalling rename
, updating/upgrading Perl, along with basic computer updates and restarting. If anyone knows what is going on to cause this, or has a solution, I'd be extremely grateful.
Danae Stephens
(11 rep)
Jul 2, 2025, 07:52 PM
• Last activity: Jul 3, 2025, 06:05 PM
0
votes
5
answers
157
views
Rename a set of files according to a specific scheme, with rename back option
In Linux in a directory there are files, `ls -1` shows me this output : file1.1-rvr file1.2-rvr file1.3 file1.4-rvr file1.5 file1.6-rvr file2.1 file2.2 file3.1 file3.10 file3.2-rvr file3.3-rvr file3.4 file3.5 file3.6 file3.7 file3.8 file3.9 file4.1 file4.2 file5.1-rvr file5.2 file6.1 file6.2 file6.3...
In Linux in a directory there are files,
ls -1
shows me this output :
file1.1-rvr
file1.2-rvr
file1.3
file1.4-rvr
file1.5
file1.6-rvr
file2.1
file2.2
file3.1
file3.10
file3.2-rvr
file3.3-rvr
file3.4
file3.5
file3.6
file3.7
file3.8
file3.9
file4.1
file4.2
file5.1-rvr
file5.2
file6.1
file6.2
file6.3
file6.4
file7.1
file7.2-rvr
file7.3
file7.4
file7.5
file7.6
file8.1
file8.2
file8.3-rvr
file8.4
In this directory are only files with file names that begin with file
.
There are no other files in there.
file1.*
is a package
file2.*
is a (different) package too
and so on.
Each package should have its own random name.
For the randomness i will use.
cat /dev/urandom | tr -cd 'a-zA-Z0-9' | head -c $(shuf -i 8-32 -n 1)
In each package, the .
should be renamed to .part.rar
.
Files with -rvr
should renamed too.
For example:
file3.1
file3.10
file3.2-rvr
file3.3-rvr
file3.4
file3.5
file3.6
file3.7
file3.8
file3.9
should be renamed for testing and experimenting to:
rfiqDLhZF5XxRcJXkqR1LrwniDi.part01.rar
rfiqDLhZF5XxRcJXkqR1LrwniDi.part10.rar
rfiqDLhZF5XxRcJXkqR1LrwniDi.part02.rar
rfiqDLhZF5XxRcJXkqR1LrwniDi.part03.rar
rfiqDLhZF5XxRcJXkqR1LrwniDi.part04.rar
rfiqDLhZF5XxRcJXkqR1LrwniDi.part05.rar
rfiqDLhZF5XxRcJXkqR1LrwniDi.part06.rar
rfiqDLhZF5XxRcJXkqR1LrwniDi.part07.rar
rfiqDLhZF5XxRcJXkqR1LrwniDi.part08.rar
rfiqDLhZF5XxRcJXkqR1LrwniDi.part09.rar
(If there are a *.10, 1 must be rename to 01.)
But there must be a way to note (in a file ../renamed
) the renaming in order to rename them back to the original filenames later.
For renaming all files in random names, i can use this, but i dont know how to work with the .part.rar renaming.
for file in file*; do
while true; do
RANDOM_NAME=$(cat /dev/urandom | tr -cd 'a-zA-Z0-9' | head -c $(shuf -i 8-32 -n 1));
if [ ! -f ${RANDOM_NAME} ]; then
echo "${file}" "${RANDOM_NAME}" >> ../renamed
mv "${file}" "${RANDOM_NAME}";
break;
fi
done
done
For renaming back, i can use this one liner :
`while read old new rest ; do mv $new $old ; done .rar and back again.
EDIT
I am looking for a way to do that in Bash.
Here is a complete list with the current file names and the new filename scheme:
current name new name
------------ --------------------------------------
file1.1-rvr --> cL5617iQyc8kT5GwNoi.part1.rar
file1.2-rvr --> cL5617iQyc8kT5GwNoi.part2.rar
file1.3 --> cL5617iQyc8kT5GwNoi.part3.rar
file1.4-rvr --> cL5617iQyc8kT5GwNoi.part4.rar
file1.5 --> cL5617iQyc8kT5GwNoi.part5.rar
file1.6-rvr --> cL5617iQyc8kT5GwNoi.part6.rar
file2.1 --> QuMPmQjppRSuG3QL9xy5.part1.rar
file2.2 --> QuMPmQjppRSuG3QL9xy5.part2.rar
file3.1 --> rfiqDLhZF5XxRcJXkqR1LrwniDi.part01.rar
file3.10 --> rfiqDLhZF5XxRcJXkqR1LrwniDi.part02.rar
file3.2-rvr --> rfiqDLhZF5XxRcJXkqR1LrwniDi.part03.rar
file3.3-rvr --> rfiqDLhZF5XxRcJXkqR1LrwniDi.part04.rar
file3.4 --> rfiqDLhZF5XxRcJXkqR1LrwniDi.part05.rar
file3.5 --> rfiqDLhZF5XxRcJXkqR1LrwniDi.part06.rar
file3.6 --> rfiqDLhZF5XxRcJXkqR1LrwniDi.part07.rar
file3.7 --> rfiqDLhZF5XxRcJXkqR1LrwniDi.part08.rar
file3.8 --> rfiqDLhZF5XxRcJXkqR1LrwniDi.part09.rar
file3.9 --> rfiqDLhZF5XxRcJXkqR1LrwniDi.part10.rar
file4.1 --> cLYtCmUW.part1.rar
file4.2 --> cLYtCmUW.part2.rar
file5.1-rvr --> uXjOgcreTUCC7aHKkXeWPL1SiVdX.part1.rar
file5.2 --> uXjOgcreTUCC7aHKkXeWPL1SiVdX.part2.rar
file6.1 --> 9CcsiBYcuASF0ECoS.part1.rar
file6.2 --> 9CcsiBYcuASF0ECoS.part2.rar
file6.3 --> 9CcsiBYcuASF0ECoS.part3.rar
file6.4 --> 9CcsiBYcuASF0ECoS.part4.rar
file7.1 --> SXKymGb5Z9ImrQ0K51IUAA.part1.rar
file7.2-rvr --> SXKymGb5Z9ImrQ0K51IUAA.part2.rar
file7.3 --> SXKymGb5Z9ImrQ0K51IUAA.part3.rar
file7.4 --> SXKymGb5Z9ImrQ0K51IUAA.part4.rar
file7.5 --> SXKymGb5Z9ImrQ0K51IUAA.part5.rar
file7.6 --> SXKymGb5Z9ImrQ0K51IUAA.part6.rar
file8.1 --> 5poLf4stv6.part1.rar
file8.2 --> 5poLf4stv6.part2.rar
file8.3-rvr --> 5poLf4stv6.part3.rar
file8.4 --> 5poLf4stv6.part4.rar
But all before .partX(X).rar
should be random and generate with :
cat /dev/urandom | tr -cd 'a-zA-Z0-9' | head -c $(shuf -i 8-32 -n 1)
Banana
(189 rep)
Jun 20, 2025, 01:32 AM
• Last activity: Jun 24, 2025, 11:13 AM
0
votes
1
answers
34
views
Rename any number of archives within a directory under a condition
I'm using ubuntu linux and have huge folders of ```.pdf``` or ```.odt``` even sometimes ```.zip``` (or sometimes other formats however the first two are the most common). To access them through the command shell easily and fast I need their names to have no spaces between words, until now I used the...
I'm using ubuntu linux and have huge folders of
.pdf
or .odt
even sometimes .zip
(or sometimes other formats however the first two are the most common). To access them through the command shell easily and fast I need their names to have no spaces between words, until now I used the command
and renamed each one by hand adding underscores ( _ ) between words wich is really time consuming. ¿Is there a way to rename files within a directory specifying the condition of replacing spaces with underscores?.
Thanks everyone, I'm new and I think I asked this question in the wrong community, hope this time is the right one.
Alberto
(1 rep)
Jun 3, 2025, 04:24 AM
• Last activity: Jun 5, 2025, 03:37 PM
2
votes
2
answers
2299
views
Copying/Moving folders where destination folder already exists
I am writing a bash script to copy/move a folder called "folder" to a directory that already contains "folder" and I would like the contents to be merged. I am attempting to use a solution from this question: [https://unix.stackexchange.com/questions/127712/merging-folders-with-mv][1] cp -rl source/...
I am writing a bash script to copy/move a folder called "folder" to a directory that already contains "folder" and I would like the contents to be merged.
I am attempting to use a solution from this question:
https://unix.stackexchange.com/questions/127712/merging-folders-with-mv
cp -rl source/folder destination
rm -r source/folder
If i type the first line in the terminal, source "folder" and destination "folder" are merged as expected.
However, When i run the script with the line in it, instead of merging the folders the destination now contains two folders; "folder" and "blank", where "blank" has the contents of the source "folder" in it.
puyanera
(21 rep)
Nov 3, 2019, 01:07 AM
• Last activity: May 30, 2025, 03:09 AM
19
votes
9
answers
75550
views
How to rename all files with special characters and spaces in a directory?
How can I rename all the files in a specific directory where the files contains blanks spaces and special characters ($ and @) in their names? I tried the `rename` command as follows to replace all the spaces and special characters with a _: $ ls -lrt total 464 -rwxr-xr-x. 1 pmautoamtion pmautoamtio...
How can I rename all the files in a specific directory where the files contains blanks spaces and special characters ($ and @) in their names?
I tried the
rename
command as follows to replace all the spaces and special characters with a _:
$ ls -lrt
total 464
-rwxr-xr-x. 1 pmautoamtion pmautoamtion 471106 Jul 17 13:14 Bharti Blocked TRX Report Morning$AP@20150716.csv
$ rename -n 's/ |\$|@/_/g' *
$ ls -lrt
total 464
-rwxr-xr-x. 1 pmautoamtion pmautoamtion 471106 Jul 17 13:14 Bharti Blocked TRX Report Morning$AP@20150716.csv
$
The command works, but won't make any changes in the file names and won't return any error either. How can in fix this and are there other ways as well?
Ankit Vashistha
(3973 rep)
Jul 17, 2015, 07:57 AM
• Last activity: Apr 22, 2025, 01:26 PM
5
votes
6
answers
1550
views
Why can't I merge folders by renaming one of them?
Try to run this mv -- "foldername...__" "foldername..." This will move folder `foldername...__` under the folder `foldername...` instead of renaming it. Why? Note that `foldername...` already exists. I want to merge them into a single directory. This may be applied to thousands of folders within a s...
Try to run this
mv -- "foldername...__" "foldername..."
This will move folder
foldername...__
under the folder foldername...
instead of renaming it. Why?
Note that foldername...
already exists. I want to merge them into a single directory. This may be applied to thousands of folders within a script. So I am searching for a general solution.
I know that one or two dots have a special meaning for Linux. But I can't find any answer to why this is happening when these dots are in the middle of the filename. And how can I do it?
## 1st UPDATE
How can I rename folders and merge them *if they already exist* with existing folders?
What I tried
rename -f "s/\.\..*/\.\./g" *
Can't rename foldername...__ foldername..: Directory not empty
(echo
must be changed to eval for execution)
for i in *.jpg; do echo "mv \"$i\" \"echo "$i" | sed 's/\.\.[0-9]\+\+/\.\./g'
\""; done;
Answers in other forums are very complex
like here
## 2nd UPDATE
mv
and rename
fail.
Then the next best thing is a script.
If after echo
applying renaming, folder names exist, move all files under the current or 1st renamed folder, and if empty, delete all other failed-to-rename folders.
Estatistics
(350 rep)
Apr 18, 2025, 07:57 AM
• Last activity: Apr 21, 2025, 04:50 PM
8
votes
4
answers
1803
views
Why do my UTF-8 filenames always match against a regex bracket expression in Perl?
Here is a script to fix broken Cyrillic filenames if the files were moved to Mac from Windows (based on an answer to https://unix.stackexchange.com/q/792464) ```perl #!/bin/zsh # Usage: # Requires Perl::Rename find "$1" -mindepth 1 -print0 | rename -0 -d -e ' use Unicode::Normalize qw(NFC); use Enco...
Here is a script to fix broken Cyrillic filenames if the files were moved to Mac from Windows (based on an answer to https://unix.stackexchange.com/q/792464)
#!/bin/zsh
# Usage:
# Requires Perl::Rename
find "$1" -mindepth 1 -print0 |
rename -0 -d -e '
use Unicode::Normalize qw(NFC);
use Encode qw(:all);
if ($_ =~ /[†°Ґ£§•¶І®©™Ђђ≠]/) {
my $check = DIE_ON_ERR | LEAVE_SRC;
my $new = eval {encode("UTF-8",
decode("cp866",
encode("mac-cyrillic",
NFC(decode("UTF-8", $_, $check)), $check), $check))
};
if ($new) {$_ = $new;} else {warn $@;}
}'
I want it to rename only those files in the target direcotry that have at least one of the following characters in their filenames: †°Ґ£§•¶І®©™Ђђ≠
. But for some reason the script renames all of the files there instead: for example, a correct filename срочно.txt
is changed to a meaningless ёЁюўэю.txt
. What I'm doing wrong?
The path to my test folder is simply /Users/john/scripts/test
: no spaces and no Cyrillic or special characters.
The script is used on macOS and with BSD-version of find
.
An update two days after the question was answered: Stéphane's Chazelas and Choroba's versions work fine for me. Terdon's version doesn't work for me yet.
jsx97
(1347 rep)
Apr 14, 2025, 08:03 PM
• Last activity: Apr 17, 2025, 03:54 AM
1
votes
3
answers
73
views
Duplicate and rename files with matching names but different extensions in bash?
Is there some *simple* way to duplicate both `.cpp` and `.h` files (or any multitude of extensions) simultaneously in `bash`, instead of: ```sh cp foo.cpp bar.cpp cp foo.h bar.h ``` I'm not looking for shell script answers or complicated `find` syntax or anything like that; I'm just wondering if the...
Is there some *simple* way to duplicate both
.cpp
and .h
files (or any multitude of extensions) simultaneously in bash
, instead of:
cp foo.cpp bar.cpp
cp foo.h bar.h
I'm not looking for shell script answers or complicated find
syntax or anything like that; I'm just wondering if there's something maybe built into bash
that does this in a simple way.
BrandonL
(180 rep)
Feb 27, 2025, 05:46 PM
• Last activity: Mar 8, 2025, 08:53 AM
2
votes
3
answers
929
views
mv files to a different path which is constructed via a regex replacement
I have a directory full of files stored in subdirectories according to their filename, i.e.: 20d1/d325/52d1/20d1d32552d1a95249e62662fbdf924dd72c4027.jpg ccaf/13cf/3199/ccaf13cf319930e80f5f2ad02525b93e1326c160.jpg ec07/53bd/2355/ec0753bd2355fa8ec5cf5163e219c162cce3b03a.jpg ... As you can see, the fir...
I have a directory full of files stored in subdirectories according to their filename, i.e.:
20d1/d325/52d1/20d1d32552d1a95249e62662fbdf924dd72c4027.jpg
ccaf/13cf/3199/ccaf13cf319930e80f5f2ad02525b93e1326c160.jpg
ec07/53bd/2355/ec0753bd2355fa8ec5cf5163e219c162cce3b03a.jpg
...
As you can see, the first 12 characters of the filename are used to create three levels of subdirectories. Unfortunately four characters per directory name were chosen, and as it happens the amount of files has grown beyond the directory limit of 32000 entries per directory on the filesystem. So they need to be rewritten to:
20d/1d3/255/2d1/20d1d32552d1a95249e62662fbdf924dd72c4027.jpg
cca/f13/cf3/199/ccaf13cf319930e80f5f2ad02525b93e1326c160.jpg
ec0/753/bd2/355/ec0753bd2355fa8ec5cf5163e219c162cce3b03a.jpg
...
So three letters per directory instead of four. There are a ton of files, so the process should be as fast as possible.
I have dabbled around with
find
:
find /path/to/files -mindepth 4 -type f -regextype posix-extended -regex \
".*/([0-9a-f]{4}/){3}(([0-9a-f]{3})([0-9a-f]{3})([0-9a-f]{3})([0-9a-f]{3})[0-9a-f]+\.\w+)"
This prints all the files nicely, but I'm not sure how to proceed with the rewriting. I'd like to use the regex capture groups in the rewrite process to rewrite the path to $3/$4/$5/$6/$2
(backreferences to find
regex). But find
doesn't seem to support something like:
find ... -exec cp {} /elsewhere/$3/$4/$5/$6/$2 ;
What is the best approach to handle this? Some combination of sed
and xargs
(I'm not very experienced with those)? Should I go for a loop instead of a find
action? I'm a little lost.
deceze
(185 rep)
Jul 28, 2013, 06:43 PM
• Last activity: Mar 2, 2025, 12:45 PM
230
votes
8
answers
505629
views
Move folder content up one level
I have a directory that is unpacked, but is in a folder. How can I move the contents up one level? I am accessing CentOS via SSH.
I have a directory that is unpacked, but is in a folder. How can I move the contents up one level? I am accessing CentOS via SSH.
whatshakin
Aug 24, 2011, 05:51 PM
• Last activity: Feb 16, 2025, 07:45 AM
6
votes
5
answers
738
views
rename files in batch
During importing my music files from backup (thanks to default naming scheme of `rhythmbox`), I have messed up the file names. Now the looks like: 00 - American Pie.ogg.ogg.ogg.ogg 00 - American Pie.ogg.ogg.ogg.ogg.ogg 00 - another brick in the wall.ogg.ogg.ogg.ogg 00 - another brick in the wall.ogg...
During importing my music files from backup (thanks to default naming scheme of
rhythmbox
), I have messed up the file names. Now the looks like:
00 - American Pie.ogg.ogg.ogg.ogg
00 - American Pie.ogg.ogg.ogg.ogg.ogg
00 - another brick in the wall.ogg.ogg.ogg.ogg
00 - another brick in the wall.ogg.ogg.ogg.ogg.ogg
00 - candle_in_the_wind.ogg.ogg.ogg.ogg
00 - candle_in_the_wind.ogg.ogg.ogg.ogg.ogg
While the file should look like
American Pie.ogg
another brick in the wall.ogg
candle_in_the_wind.ogg
And I have (as from wc -l
) 3096 such files. How can I restore it in batch mode?
I have tried rename
and mmv
to work, as given in the ans of this question, but not working (problem with the rename
syntax, and for mmv
,there is collision).
Any help please?
BaRud
(1699 rep)
Jan 23, 2014, 07:21 PM
• Last activity: Feb 7, 2025, 05:24 PM
0
votes
1
answers
60
views
Is there a tool to "recursively" move/rename a directory (with conflicts/merging)?
Imagine I want to move (rename) a directory tree `/var/lib/postgres/data` to `/var/lib/postgres/data.old`: ``` /var/lib/postgres └── data ├── base │   ├── 16390 │   │   └── │   └── │   └── ├── global │   └── ├── pg_wal │   ├── │&#...
Imagine I want to move (rename) a directory tree
/var/lib/postgres/data
to /var/lib/postgres/data.old
:
/var/lib/postgres
└── data
├── base
│ ├── 16390
│ │ └──
│ └──
│ └──
├── global
│ └──
├── pg_wal
│ ├──
│ ├── archive_status
│ └── summaries
├──
└── postmaster.pid
Typically, it's a single rename()
syscall away and a single command away: mv data data.old
.
However, imagine that there is an active mountpoint somewhere in that directory tree, e.g., pg_wal
is a different filesystem:
$ findmnt
├─/var/lib/postgres stank/data/stratofortress/PostgreSQL zfs rw,noatime,xattr,posixacl,casesensitive
│ └─/var/lib/postgres/data/pg_wal stank/data/stratofortress/PostgreSQL/pg_wal zfs rw,noatime,xattr,posixacl,case-sensitive
Alternatively, imagine that the target name (data.old
) already exists and some branches of the directory tree are already created (because they are mountpoints, in the same vein as above).
~~In both these cases~~ In the latter case, mv
will refuse to do anything. Performing a deep copy with something like a cp -a
is prohibitively expensive, and reflinks are unavailable for reasons that are outside of the scope of this question.
---
Is there a tool that can perform an optimal "recursive move", iteratively descending into parts of the source hierarchy for each subtree that cannot be renamed wholesale, up to individual files (finally falling back to making a copy of each individual file if needed)?
**NB: I'm looking for a generalized solution that can be extended to any number of subtrees and conflicts, i.e., mv data/* -t data.old; mv data/pg_wal/* -t data.old/pg_wal
is not a solution. In other words, please do not infer any constraints or special cases from the example above.**
intelfx
(5699 rep)
Jan 20, 2025, 08:45 PM
• Last activity: Jan 22, 2025, 06:09 AM
0
votes
0
answers
41
views
Rename multiple files (bulk rename) disabled in MATE v: 1.26.2 (marco v: 1.26.2) on Linux Mint 22 (Wilma)
Before my last system upgrade, I enjoyed the functionality of renaming multiple files in the system GUI file manager (I use Marco in MATE). This is also called "bulk rename", e.g. [here][1]. However, I notice that this functionality has been disabled in my new version (MATE v: 1.26.2 (marco v: 1.26....
Before my last system upgrade, I enjoyed the functionality of renaming multiple files in the system GUI file manager (I use Marco in MATE).
This is also called "bulk rename", e.g. here .
However, I notice that this functionality has been disabled in my new version (MATE v: 1.26.2 (marco v: 1.26.2) on Linux Mint 22 (Wilma)),and I have read that this is because of potential risks.
I have searched around, but I have found only instructions on how to enable back this functionality for Cinnamon, here .
Can someone help me with MATE?
Fabio
(535 rep)
Jan 19, 2025, 11:42 AM
• Last activity: Jan 19, 2025, 12:09 PM
3
votes
1
answers
225
views
Replace accented characters with perl-rename
I'm standardizing the name of several files at once, so I wrote a regex for `perl-rename`: perl-rename 'y/A-Z/a-z/; s/ã|á|â/a/g; s/é|ê/e/g; s/í/i/g; s/õ|ó/o/g; s/ú/u/g; s/ç/c/g; s/(? 2024-12-01-certidao_de_matricula However, I thought it could be sim...
I'm standardizing the name of several files at once, so I wrote a regex for
perl-rename
:
perl-rename 'y/A-Z/a-z/; s/ã|á|â/a/g; s/é|ê/e/g; s/í/i/g; s/õ|ó/o/g; s/ú/u/g; s/ç/c/g; s/(? 2024-12-01-certidao_de_matricula
However, I thought it could be simplified a bit, so I came up with this:
perl-rename 'y/A-Z/a-z/; y/ãáâéêíõóúç/aaaeeioouc/; s/(? 2024-12-01-certidaao_de_matraccula
Why is the second command not working, since it should be doing a direct transliteration of each accented character? I can't even make sense of the outcome. Thanks in advance.
Alex Braga
(133 rep)
Dec 24, 2024, 07:30 PM
• Last activity: Dec 24, 2024, 10:39 PM
37
votes
14
answers
62649
views
Preserve directory structure when moving files using find
I have created the following script that move old days files as defined from source directory to destination directory. It is working perfectly. #!/bin/bash echo "Enter Your Source Directory" read soure echo "Enter Your Destination Directory" read destination echo "Enter Days" read days find "$soure...
I have created the following script that move old days files as defined from source directory to destination directory. It is working perfectly.
#!/bin/bash
echo "Enter Your Source Directory"
read soure
echo "Enter Your Destination Directory"
read destination
echo "Enter Days"
read days
find "$soure" -type f -mtime "-$days" -exec mv {} "$destination" \;
echo "Files which were $days Days old moved from $soure to $destination"
This script moves files great, It also move files of source subdirectory, but it doesn't create subdirectory into destination directory. I want to implement this additional feature in it.
with example
/home/ketan : source directory
/home/ketan/hex : source subdirectory
/home/maxi : destination directory
When I run this script , it also move hex's files in maxi directory, but I need that same hex should be created into maxi directory and move its files in same hex there.
KK Patel
(1885 rep)
Dec 21, 2012, 02:26 PM
• Last activity: Dec 18, 2024, 10:23 AM
0
votes
0
answers
86
views
I accidentally rename lib/ld-linux-aarch64.so.1 file on my target machine, what should i do?
I accidentally renamed ld-linux-aarch64.so.1. Now I cannot connect my target machine with SSH. How can I rename it back? I will not consider to reflash my target machine.
I accidentally renamed ld-linux-aarch64.so.1. Now I cannot connect my target machine with SSH. How can I rename it back? I will not consider to reflash my target machine.
M. Preacher
(1 rep)
Nov 9, 2024, 08:44 PM
• Last activity: Nov 9, 2024, 08:51 PM
1
votes
3
answers
5519
views
Making a pipe from `ls` to `mv`
I am trying to make a small utility for myself on the command line - for a given current work directory I would like to find the most recently added file and `mv` it to a name given by argument I have been trying to achieve this via: `ls -tr | tail -n 1 | xargs -0 -J % mv % SQL_warning_2.png` ...how...
I am trying to make a small utility for myself on the command line - for a given current work directory I would like to find the most recently added file and
mv
it to a name given by argument
I have been trying to achieve this via:
ls -tr | tail -n 1 | xargs -0 -J % mv % SQL_warning_2.png
...however bash reports:
mv: rename Screenshot 2020-06-22 at 17.53.23.png
to SQL_warning_2.png: No such file or directory
I would guess that this means that xargs is making separate arguments via spaces in the filename: Screenshot 2020-06-22 at 17.53.23.png
, but there is no -print0
flag for ls
that I am aware of.
If some of my assumptions are incorrect please excuse me - I am very unfamiliar with xargs
Scott Anderson
(133 rep)
Jun 22, 2020, 03:16 PM
• Last activity: Oct 6, 2024, 09:13 AM
0
votes
1
answers
143
views
How to prevent growisofs from renaming files?
I was trying to copy several files to a DVD with `growisofs`. The command I use is: ```lang-shell growisofs -Z /dev/dvd -R -J /media/34GB/tmp/ ``` But when I send it to command line, I receive this message ```none I: -input-charset not specified, using utf-8 (detected in locale settings) ``` and the...
I was trying to copy several files to a DVD with
growisofs
. The command I use is:
-shell
growisofs -Z /dev/dvd -R -J /media/34GB/tmp/
But when I send it to command line, I receive this message
I: -input-charset not specified, using utf-8 (detected in locale settings)
and then countless messages like these for many of my files.
Using F1_SC000.JPG;1 for /media/34GB/tmp/imagens/paper doll ultimos/F1-SCAN1194.JPG (F1-SCAN1189.JPG)
How can I avoid these renaming?
I made a full record, and to my surprise, the final file names are correct, despite the renaming messages. Why these messages appeared then?
user2752471
(265 rep)
Jun 11, 2017, 10:27 PM
• Last activity: Sep 17, 2024, 02:38 PM
Showing page 1 of 20 total questions