Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
7
votes
8
answers
18899
views
Remove numbers from the start of filenames
I've a problem modifying the files' names in my `Music/` directory. I have a list of names like these: $ ls 01 American Idiot.mp3 01 Articolo 31 - Domani Smetto.mp3 01 Bohemian rapsody.mp3 01 Eye of the Tiger.mp3 04 Halo.mp3 04 Indietro.mp3 04 You Can't Hurry Love.mp3 05 Beautiful girls.mp3 16 Apolo...
I've a problem modifying the files' names in my
Music/
directory.
I have a list of names like these:
$ ls
01 American Idiot.mp3
01 Articolo 31 - Domani Smetto.mp3
01 Bohemian rapsody.mp3
01 Eye of the Tiger.mp3
04 Halo.mp3
04 Indietro.mp3
04 You Can't Hurry Love.mp3
05 Beautiful girls.mp3
16 Apologize.mp3
16 Christmas Is All Around.mp3
Adam's song.mp3
A far l'amore comincia tu.mp3
All By My Self.MP3
Always.mp3
Angel.mp3
And similar and I would like to cut all the numbers in front of the filenames (not the 3 in the extension).
I've tried first to grep
only the files with the number with find -exec
or xargs
but even at this first step I had no success. After being able to grep
I'd like doing the actual name change.
This is what I tried by now:
ls > try-expression
grep -E '^[0-9]+' try-expression
and with the above I got the right result. Then I tried the next step:
ls | xargs -0 grep -E '^[0-9]+'
ls | xargs -d '\n' grep -E '^[0-9]+'
find . -name '[0-9]+' -exec grep -E '^[0-9]+' {} \;
ls | parallel bash -c "grep -E '^[0-9]+'" - {}
And similar but I got error like 'File name too long' or no output at all. I guess the problem is the way I'm using xargs
or find
as expressions in separate commands work well.
Thank you for your help
Luigi Tiburzi
(887 rep)
May 29, 2012, 08:07 AM
• Last activity: May 14, 2025, 11:19 AM
10
votes
8
answers
9977
views
How to recover “deleted” files in Linux on an NTFS filesystem (files originally from macOS)
My girlfriend has a external hard disk with 10 years+ of photos, documents and more. A lot of these files originate from her old iPhone 5 and her MacBook. The hard disk itself is NTFS Format. Since the disk is so old, it turns into a hazard of data loss (what an irony). As we tried to upload all the...
My girlfriend has a external hard disk with 10 years+ of photos, documents and more. A lot of these files originate from her old iPhone 5 and her MacBook. The hard disk itself is NTFS Format. Since the disk is so old, it turns into a hazard of data loss (what an irony).
As we tried to upload all the files into OneDrive to store them safely, we got 1,000s of errors because of invalid file names. I realized that many files started with
._
, e.g. ./pic/92 win new/iphone/._IMG_1604.JPG
. I don't understand macOS and why files should be named like that, but for sure you can never get them into OneDrive like that.
So I decided to hook it to my Raspberry Pi and rename all files with the wrong characters from the command line. After listing the nearly 10,000 files, I ran the following over the whole hard disk.
find . -name "._*" | sed -e "p;s/\._//" | xargs -d '\n' -n2 mv
Furthermore, I removed some leading whitespace in filenames with zmv.
I tried the command in a test environment first and it looked fine. But I didn't check the file size.
After my girlfriend connected the hard disk back onto her Mac, all renamed files show a file size of 4KB (empty)! **I screwed it up** and I don't know how.
I assume the data is still there, but I somehow screwed the filesystem.
Does anybody understand what I did wrong? More importantly, do you see a chance to recover the files? I would appreciate any advice.
LukasH
(109 rep)
Mar 6, 2021, 05:15 PM
• Last activity: Apr 26, 2025, 09:30 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
23
votes
3
answers
9929
views
I lost files by using the "mv" command and I don't know where they are!
I lost some files by using the `mv` command. I don't know where they are. They are not in the directory to which I intended to copy them. Below is a transcript of what I did: $ ls Desktop Documents Downloads GameShell Music Pictures pratice Public Templates Videos $ mkdir tp2 $ ls Desktop Documents...
I lost some files by using the
mv
command. I don't know where they are. They are not in the directory to which I intended to copy them.
Below is a transcript of what I did:
$ ls
Desktop Documents Downloads GameShell Music Pictures pratice Public Templates Videos
$ mkdir tp2
$ ls
Desktop Documents Downloads GameShell Music Pictures pratice Public Templates tp2 Videos
$ cd Downloads/221-tp2-public-main/
$ ls
backup copybash Dockerfile ntfy-1.16.0 packets.txt README.md restore secret
cloud data Dockerfile_CAYS07019906 ntfy.zip rapport-tp2.md remplacer.sed sauvegarde.sh tail
$ mv rapport-tp2.md tp2
$ mv Dockerfile_CAYS07019906 tp2
$ mv packets.txt tp2
$ mv sauvegarde.sh tp2
$ cd
$ cd tp2/
$ ls
$ ls -l
total 0
$ cd ..
Samuel Cayo
(339 rep)
Apr 24, 2022, 01:01 AM
• Last activity: Mar 20, 2025, 01:15 PM
5
votes
2
answers
109
views
mv affected by bind mounts (feels like a bug)
Originally, `mv(1)` was a rename operation; it updated names in filesystems and did not copy files. More recently, a convenience feature was added, whereby if the source and target were on different filesystems, it would copy and delete the files. AKA "inter-device move". Now I was trying to tidy up...
Originally,
mv(1)
was a rename operation; it updated names in filesystems and did not copy files. More recently, a convenience feature was added, whereby if the source and target were on different filesystems, it would copy and delete the files. AKA "inter-device move".
Now I was trying to tidy up my backups. I wanted to move .../rest2/Public/Backups
to .../rest2/Backup/(Backups)
, so:
root@ts412:/QNAP/mounts/rest2# mv Public/Backups Backup/
Where:
root@ts412:/QNAP/mounts/rest2# df -h /QNAP/mounts/rest2/Public/
Filesystem Size Used Avail Use% Mounted on
/dev/sdb10 831G 715G 75G 91% /QNAP/mounts/rest2
root@ts412:/QNAP/mounts/rest2# df -h /QNAP/mounts/rest2/Backup/
Filesystem Size Used Avail Use% Mounted on
/dev/sdb10 831G 715G 75G 91% /QNAP/mounts/rest2
So same filesystem:
(FYI, rest2
is "the rest of the space on disk2
")
But the move started to behave like an "inter-device move" (high CPU, disks busy, various errors about non-empty directories etc.), so I killed it.
Checking in a slightly different fashion (note the .
) :
root@ts412:/QNAP/mounts/rest2# df -h Backup/.
Filesystem Size Used Avail Use% Mounted on
/dev/sdb10 831G 715G 75G 91% /QNAP/mounts/rest2
root@ts412:/QNAP/mounts/rest2# df -h Public/Backups/.
Filesystem Size Used Avail Use% Mounted on
/dev/sdb10 831G 715G 75G 91% /QNAP/mounts/rest2/Public
Then I recall I ALSO had a **bind mount** (it makes the shared names via NFS more friendly).
So I unmounted the extra bind mount:
root@ts412:/QNAP/mounts/rest2# umount /QNAP/mounts/rest2/Public
root@ts412:/QNAP/mounts/rest2# df -h Public/Backups/.
Filesystem Size Used Avail Use% Mounted on
/dev/sdb10 831G 715G 75G 91% /QNAP/mounts/rest2
root@ts412:/QNAP/mounts/rest2# mv Public/Backups Backup/
And the mv(1)
was instant, as I'd expected.
So, notwithstanding the extra mount(8)
s, **the source and target were always in the same filesystem**, the mount -o bind /QNAP/mounts/rest2/Backups /Backups
does not affect this. So I'm wondering if mv(1)
gets back mount points of /QNAP/mounts/rest2
for one and /QNAP/mounts/rest2/Public
for the other, it incorrectly decides the two files are on different filesystems?
GraemeV
(348 rep)
Mar 11, 2025, 01:40 PM
• Last activity: Mar 18, 2025, 08:34 PM
211
votes
14
answers
265068
views
How can I move files and view the progress (e.g. with a progress bar)?
When moving large directories using `mv`, is there a way to view the progress (%)? The `cp` command on gentoo had a `-g` switch that showed the progress.
When moving large directories using
mv
, is there a way to view the progress (%)?
The cp
command on gentoo had a -g
switch that showed the progress.
letronje
(2305 rep)
Oct 1, 2010, 06:11 AM
• Last activity: Mar 17, 2025, 04:37 PM
136
votes
10
answers
216178
views
Solving "mv: Argument list too long"?
I have a folder with more than a million files that needs sorting, but I can't really do anything because `mv` outputs this message all the time -bash: /bin/mv: Argument list too long I'm using this command to move extension-less files: mv -- !(*.jpg|*.png|*.bmp) targetdir/
I have a folder with more than a million files that needs sorting, but I can't really do anything because
mv
outputs this message all the time
-bash: /bin/mv: Argument list too long
I'm using this command to move extension-less files:
mv -- !(*.jpg|*.png|*.bmp) targetdir/
Dominique
(5465 rep)
May 8, 2014, 11:31 PM
• Last activity: Mar 17, 2025, 10:02 AM
0
votes
1
answers
140
views
script appears to run with no progress
This script is to find a list of files stored in a text file, and if the files are found, copy them to a specific location. So far I have had success running the portions up to but not including the portion that actually copies the files. When I add the code to copy the file, starting with exec, the...
This script is to find a list of files stored in a text file, and if the files are found, copy them to a specific location. So far I have had success running the portions up to but not including the portion that actually copies the files. When I add the code to copy the file, starting with exec, the script no longer appears to work and makes no progress. I would like to understand what is locking this script up and how to make it work correctly. Thanks!
#!/bin/bash
#Find files from a list in a file and copy them to a common folder
mapfile -t filelist < filelist.txt
for file in "${filelist[@]}"; do
xargs find ~ -name '${filelist[@]}' -exec mv -t ~/Document/foundfiles/ {} +;
done
user289380
May 8, 2018, 12:43 AM
• Last activity: Mar 17, 2025, 07:24 AM
0
votes
1
answers
114
views
Help - I moved everything in the root directory to a directory of mine
So I was moving some files, I meant: mv ./* ~/something But I typed: mv /* something Now I can't boot up my computer and I couldn't because `me: ls output: -bash: /bin/ls: No such file or directory` Raspi OS most recent, I just updated. I have no backup, please help me.
So I was moving some files, I meant:
mv ./* ~/something
But I typed:
mv /* something
Now I can't boot up my computer and I couldn't because
me: ls output: -bash: /bin/ls: No such file or directory
Raspi OS most recent, I just updated.
I have no backup, please help me.
Nobody Nobody
(1 rep)
Feb 1, 2025, 01:41 AM
• Last activity: Feb 1, 2025, 10:45 PM
32
votes
10
answers
14932
views
How to move directory into a directory with the same name?
I have a directory `foo` with several files: ``` . └── foo ├── a.txt └── b.txt ``` and I want to move it into a directory with the same name: ``` . └── foo └── foo ├── a.txt └── b.txt ``` I'm currently creating a temporary directory `bar`, move `foo` into `bar` and rename `bar` to `foo` afterwards:...
I have a directory
foo
with several files:
.
└── foo
├── a.txt
└── b.txt
and I want to move it into a directory with the same name:
.
└── foo
└── foo
├── a.txt
└── b.txt
I'm currently creating a temporary directory bar
, move foo
into bar
and rename bar
to foo
afterwards:
mkdir bar
mv foo bar
mv bar foo
But this feels a little cumbersome and I have to pick a name for bar
that's not already taken.
Is there a more elegant or straight-forward way to achieve this? I'm on macOS if that matters.
Stefan
(431 rep)
Dec 1, 2019, 01:09 PM
• Last activity: Jan 20, 2025, 06:53 AM
0
votes
1
answers
687
views
Help with -maxdepth in 'find -exec mv' command line
I'm working on a sorting/filtering cron script to process incoming files based on a set of constant strings (logfile, history, dataset, etc). The files to be sorted all sit under a common folder, some in the main folder and some in subfolders. I'm working on this on Debian/bash (MX Linux) and for no...
I'm working on a sorting/filtering cron script to process incoming files based on a set of constant strings (logfile, history, dataset, etc). The files to be sorted all sit under a common folder, some in the main folder and some in subfolders. I'm working on this on Debian/bash (MX Linux) and for now that's my main concern, but it will eventually be moved to a Debian/ash (dCore Linux) system.
- file and folder names *always* contain STRING, and STRING can contain mixed case.
- filename and the subfolder in which it sits can *both* contain STRING.
- folders *with* STRING can contain files *without* STRING. They should get moved along with their parent folders.
- file and folder names can contain spaces, parentheses, brackets.
example:
/main/ # folder being searched
/main/filename.log # should not be moved
/main/filename containing-STRING.log # should be moved
/main/subfolder/ # should not be moved
/main/subfolder/file.txt # should not be moved
/main/subfolder.with STRING in-name/ # should be moved
/main/subfolder.with STRING in-name/STRING-file.log # should be moved along with parent
/main/subfolder.with STRING in-name/file.txt # should be moved along with parent
My starting point:
find . -iname '*STRING*' -exec mv {} ../offload/ \;
This works, even though it gives "file not found" errors, presumably because the files have already been moved when their parent folders were moved. Since any subfolders will always contain STRING, I don't necessarily need or want to 'find' their contents. I only have to move the parent folders. So I'm trying to use '-maxdepth 0' to only 'find' STRING in the main folder.
find . -maxdepth 0 -iname '*STRING*' -exec mv {} ../offload/ \;
The addition of the -maxdepth switch isn't working. There are no 'file not found' warnings, but also nothing gets moved. Any suggestions on where I'm going wrong?
EDIT:
I only have access to bash shell and eventually the dCore system with its default ash shell. It's a mini cli-only system; no space for adding another shell environment.
I have tried:
find . -maxdepth 0 -type d -iname '*STRING*' -exec mv {} ../offload/ \;
When I run it, it returns me to the prompt without errors but nothing has been moved.
@cas Yes I do need to preserve directory structure, but neither of your examples should satisfy the search. I only want to find and move files and directories that match STRING in the main folder. Thus:
/main/filename-with-STRING # match
/main/folder-with-STRING/ # match
/main/folder-with-STRING/foo/ # moved along with parent
/main/subfolder/filename-with-STRING # no match
/main/subfolder/folder-with-STRING/ # no match
graphics.guy
(31 rep)
Mar 21, 2023, 11:24 PM
• Last activity: Jan 15, 2025, 01:08 PM
1
votes
6
answers
288
views
Move a lot of folders with spaces in the name
I have a lot of webpages saved in my Download folder and I want to move all html files together with its folder (for every "NAME.html" exists "NAME_files/" folder). The big problem I can't deal is with the space in the name. I thinkered around this and after some attempts I did this: ``` export OLDI...
I have a lot of webpages saved in my Download folder and I want to move all html files together with its folder (for every "NAME.html" exists "NAME_files/" folder).
The big problem I can't deal is with the space in the name.
I thinkered around this and after some attempts I did this:
When I do my command only the html file go in 000 folder, but not the folder!
Yes, I know, the name, "[FreeFileSync] SyncSettings-Contabilità ⚠️.html" is a very **bad** name... 😅
I tried also with less exotic names with same results.
Please help me, where is my mistake?
export OLDIFS="$IFS"
export IFS=$'\n'
then:
for FILE in $(find . -type d -iname "*_files" ) ; do DIR=$(basename ${FILE/_files/}); WEB="${DIR}.html" ; mv "${DIR}" 000 ; mv "${WEB}" 000 ; done
I think i've quoted everything, but it doesn't works.
Or better, the command above move the html files but I receive the "No such file or directory" for the folders.
For example, I have this files :


Antonio
(193 rep)
Jan 12, 2025, 09:07 PM
• Last activity: Jan 14, 2025, 02:35 PM
4
votes
2
answers
406
views
Optimize rsync when large files move around on the source
Say I have a large directory tree of large files on disc A. I backup that tree with `rsync -a --delete /A /B`. So far so good. Between backups there are some added files, some renamed ones, the usual. Where it gets interesting is that A gets regularly reorganized: files move around (renamed, changed...
Say I have a large directory tree of large files on disc A. I backup that tree with
rsync -a --delete /A /B
. So far so good. Between backups there are some added files, some renamed ones, the usual.
Where it gets interesting is that A gets regularly reorganized: files move around (renamed, changed directories or both). So rsync
ends up deleting files on B to copy them over again from A, and with large files through a network, that takes forever.
Is there some rsync option I could use ? I've re-read the option list and I couldn't find anything relevant, something to do with --size-only
would be fine with me (low risk of collisions).
I think the solution is probably more to have a script look at file size + checksum and move files around on B *before* running rsync, but that's not too easy either.
Ideas ?
dargaud
(617 rep)
Dec 20, 2024, 09:05 AM
• Last activity: Dec 20, 2024, 02:02 PM
1
votes
1
answers
140
views
Recursively move and overwrite
I am using Ubuntu 24.10 and have a directory containing files and subdirectories: ``` main-dir file1 file2 file3 subdir1 file1-1 file1-2 subdir1-1 file1-1-1 file1-1-2 subdir1-2 file1-2-1 subdir1-2-1 ... ``` And I have a directory tree containing "corrected" files: ``` corrections-dir file2 subdir1 f...
I am using Ubuntu 24.10 and have a directory containing files and subdirectories:
main-dir
file1
file2
file3
subdir1
file1-1
file1-2
subdir1-1
file1-1-1
file1-1-2
subdir1-2
file1-2-1
subdir1-2-1
...
And I have a directory tree containing "corrected" files:
corrections-dir
file2
subdir1
file1-1
subdir1-1
file1-1-1
subdir1-2
file1-2-1
I want to recursively move and overwrite all files from corrections-dir
to main-dir
. However, the mv
command doesn't seem to have a recursive option. I know I could instead do this:
cp -R corrections-dir main-dir
rm -r corrections-dir
But the files are large and that command takes time and unnecessarily writes to new sectors of my SSD (thereby shortening its life).
Is there a way to use mv
recursively?
k314159
(481 rep)
Nov 25, 2024, 09:04 AM
• Last activity: Nov 25, 2024, 03:40 PM
1
votes
1
answers
178
views
Why does my bash shell script not work in MacOS Terminal?
I have a bash shell script ```change_filename.sh``` containing the line of code: ``` mv "dir\ 1/file1.txt" "dir\ 1/file2.txt" ``` which does not change the name of ```file1.txt``` to ```file2.txt``` as expected but produces the error message: ``` mv: rename dir\ 1/file1.txt to dir\ 1/file2.txt: No s...
I have a bash shell script
.sh
containing the line of code:
mv "dir\ 1/file1.txt" "dir\ 1/file2.txt"
which does not change the name of .txt
to .txt
as expected but produces the error message:
mv: rename dir\ 1/file1.txt to dir\ 1/file2.txt: No such file or directory
It works when I type the same line in Terminal but not in the script.
Why does the script not work?
sjl26916091
(35 rep)
Nov 25, 2024, 03:09 PM
• Last activity: Nov 25, 2024, 03:27 PM
4
votes
4
answers
14742
views
Move or copy without overwrite and check success
**Problem:** I'm looking for a way to rename or copy a file without overwriting the destination file, if it exists, and then check the success of the move or copy operation. I'm seeking a method that will work with the BSD versions of mv/cp installed on MacOS/Unix, and also the GNU coreutils version...
**Problem:**
I'm looking for a way to rename or copy a file without overwriting the destination file, if it exists, and then check the success of the move or copy operation. I'm seeking a method that will work with the BSD versions of mv/cp installed on MacOS/Unix, and also the GNU coreutils versions I have on Linux.
**Solution attempt:**
In all versions of mv/cp, I can prevent overwriting the destination file with the
-n
flag:
mv -n file1 file2
cp -n file1 file2
Similar questions suggest testing the success of mv and cp using the exit status, which is 0 if successful and >0 if an error occurred. However, for both versions of mv/cp, the exit code is 0 when the destination file already exists and the -n
flag is used.
The only other option I can think of is to also use the -v
flag, and look at the output of the command:
mv -nv file1 file2
cp -nv file1 file2
However, the GNU and BSD versions of mv/cp behave differently when the -nv
flags are used and file2 already exists: the GNU versions of mv/cp return nothing, whereas the BSD versions return file2 not overwritten
.
Our previous method was to check whether the destination file exists first, then do the mv/cp operation. Believe it or not, this caused problems because the destination file would sometimes get created by another process between the time that the check was performed and the mv/cp operation was executed.
Is there a way to accomplish this task that works with both BSD and GNU versions of mv/cp?
Alternatively, is there are way to do this using Python 2? I couldn't find a way to do this using os.rename()
srcerer
(141 rep)
Jan 25, 2019, 06:46 PM
• Last activity: Nov 25, 2024, 01:26 AM
0
votes
0
answers
294
views
How can I restore the /usr/lib/x86_64-linux-gnu folder?
I'm new to Linux and did something stupid. I'm using Kali and after apt-get update and apt-get upgrade, I encountered some issues. The desktop items were missing and windows no longer had a "bar", along with some other things. While trying to fix that, I messed it up way more.. I found that it was c...
I'm new to Linux and did something stupid. I'm using Kali and after apt-get update and apt-get upgrade, I encountered some issues. The desktop items were missing and windows no longer had a "bar", along with some other things. While trying to fix that, I messed it up way more..
I found that it was caused by a libGL error where it failed to load the swrast driver.
Someone on this site suggested renaming
/usr/lib/x86_64-linux-gnu
to /usr/lib/x86_64-linux-gnu.bak
which I did with the mv command.
It was stupid to do so without thinking about what that could impact. Now I can no longer run most commands (I will get an error: :2: /usr/lib/command-not-found: bad interpreter: /usr/bin/python3: no such file or directory
) I'm trying to move the folder back with /usr/lib/x86_64-linux-gnu.bak /usr/lib/x86_64-linux-gnu
but it results in the same error. So does using BusyBox.
I've tried using ../sbin/sln x_86-64-linux-gnu.bak x_86-64-linux-gnu
but it says there is no such file or directory.
Any ideas on what I can try or have I already lost all my data?
amberiscool
(1 rep)
Oct 8, 2024, 11:43 AM
65
votes
5
answers
12351
views
After accidentally renaming /usr, how do I rename it back?
I accidentally renamed the directory `/usr` into `/usr_bak`. I want to change it back, so I append the path `/usr_bak/bin` to `$PATH` to allow the system to find the command `sudo`. But now `sudo mv /usr_bak /usr` gives me the error: sudo: error while loading shared libraries: libsudo_util.so.0: can...
I accidentally renamed the directory
/usr
into /usr_bak
.
I want to change it back, so I append the path /usr_bak/bin
to $PATH
to allow the system to find the command sudo
.
But now sudo mv /usr_bak /usr
gives me the error:
sudo: error while loading shared libraries: libsudo_util.so.0: cannot open shared object file: No such file or directory
Is there a way to rename the /usr_bak
as /usr
besides reinstalling the system?
Yves
(3401 rep)
Mar 19, 2018, 03:17 AM
• Last activity: Sep 22, 2024, 04:48 PM
0
votes
1
answers
43
views
`mv dir/file1 ..` removed file completely
Being in `~/dir1`, I wanted to move the file `~/dir1/subdir1/file1` into `~`. I executed `mv subdir1/file1 ..`. No error occured. `~/dir1/subdir1` is empty, but I cannot find the file `file1`. Not in `~` and not in `~/dir`. Being in `~` and having the file `~/dir2/file2`, when executing `mv dir2/fil...
Being in
~/dir1
, I wanted to move the file ~/dir1/subdir1/file1
into ~
. I executed mv subdir1/file1 ..
. No error occured. ~/dir1/subdir1
is empty, but I cannot find the file file1
. Not in ~
and not in ~/dir
.
Being in ~
and having the file ~/dir2/file2
, when executing mv dir2/file2 ..
, I get the error message
mv: cannot move 'dir2/file2' to '../file2': Permission denied
which is understandable as ..
is the /home
directory where I have no rights to write.
I am a little bit confused as the mv
command seems to have different behaviours on my linux installation. Furthermore, I wonder if I can get back my first file (file1
) as I accidentally deleted an important file that way.
Niklas Netter
(31 rep)
Sep 3, 2024, 08:30 AM
• Last activity: Sep 22, 2024, 12:40 PM
1
votes
2
answers
479
views
How to move a bunch of files in their own new folder
I have a list of files in a folder: ./file1.ext ./file2.ext2 ./file3.ext I want to move all these files in their own new folder with their related name, like: ./file1/file1.ext ./file2/file2.ext2 ./file3/file3.ext Is there a way to do so in very few commands?
I have a list of files in a folder:
./file1.ext
./file2.ext2
./file3.ext
I want to move all these files in their own new folder with their related name, like:
./file1/file1.ext
./file2/file2.ext2
./file3/file3.ext
Is there a way to do so in very few commands?
pascalbrax
(13 rep)
Oct 6, 2022, 07:00 AM
• Last activity: Sep 15, 2024, 03:27 PM
Showing page 1 of 20 total questions