UNIX: How to change all hidden files to visible in a multiple sub directories
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I have hundreds of sub directories in a directory that all have hidden files in them that I need to remove the period at the beginning of them to make them visible. I found a command to go into each directory and change them to make them visible but I need to know how to make this command work from one directory up.
rename 's/.//;' .*
I have tried about an hour to modify this to work one level up but don't understand the perl string enough to do it. If someone could help out I am sure it's simple and I just can't land on the right answer.
linux files rename dot-files
add a comment |Â
up vote
2
down vote
favorite
I have hundreds of sub directories in a directory that all have hidden files in them that I need to remove the period at the beginning of them to make them visible. I found a command to go into each directory and change them to make them visible but I need to know how to make this command work from one directory up.
rename 's/.//;' .*
I have tried about an hour to modify this to work one level up but don't understand the perl string enough to do it. If someone could help out I am sure it's simple and I just can't land on the right answer.
linux files rename dot-files
Try it like thisrename -n 's/.//;' ../*
the-n
will see what happens without making any changes, then when your ok with it remove the-n
option
â George Udosen
Oct 1 '17 at 23:05
I tried this command and its looking at the files above the directory I'm in not below? copied and pasted directly into putty
â Ortoch
Oct 1 '17 at 23:23
What doesfrom one directory up
mean?
â George Udosen
Oct 1 '17 at 23:25
If it's just a matter of visibility:alias ls='ls -a'
andshopt -s dotglob
(inbash
).
â Kusalananda
Oct 2 '17 at 5:45
If you're happy with one or several of the answers, upvote them. If one is solving your issue, accepting it would be the best way of saying "Thank You!" :-)
â Kusalananda
Oct 8 '17 at 15:40
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have hundreds of sub directories in a directory that all have hidden files in them that I need to remove the period at the beginning of them to make them visible. I found a command to go into each directory and change them to make them visible but I need to know how to make this command work from one directory up.
rename 's/.//;' .*
I have tried about an hour to modify this to work one level up but don't understand the perl string enough to do it. If someone could help out I am sure it's simple and I just can't land on the right answer.
linux files rename dot-files
I have hundreds of sub directories in a directory that all have hidden files in them that I need to remove the period at the beginning of them to make them visible. I found a command to go into each directory and change them to make them visible but I need to know how to make this command work from one directory up.
rename 's/.//;' .*
I have tried about an hour to modify this to work one level up but don't understand the perl string enough to do it. If someone could help out I am sure it's simple and I just can't land on the right answer.
linux files rename dot-files
linux files rename dot-files
edited Oct 8 '17 at 12:33
Jeff Schaller
32.3k849109
32.3k849109
asked Oct 1 '17 at 22:39
Ortoch
313
313
Try it like thisrename -n 's/.//;' ../*
the-n
will see what happens without making any changes, then when your ok with it remove the-n
option
â George Udosen
Oct 1 '17 at 23:05
I tried this command and its looking at the files above the directory I'm in not below? copied and pasted directly into putty
â Ortoch
Oct 1 '17 at 23:23
What doesfrom one directory up
mean?
â George Udosen
Oct 1 '17 at 23:25
If it's just a matter of visibility:alias ls='ls -a'
andshopt -s dotglob
(inbash
).
â Kusalananda
Oct 2 '17 at 5:45
If you're happy with one or several of the answers, upvote them. If one is solving your issue, accepting it would be the best way of saying "Thank You!" :-)
â Kusalananda
Oct 8 '17 at 15:40
add a comment |Â
Try it like thisrename -n 's/.//;' ../*
the-n
will see what happens without making any changes, then when your ok with it remove the-n
option
â George Udosen
Oct 1 '17 at 23:05
I tried this command and its looking at the files above the directory I'm in not below? copied and pasted directly into putty
â Ortoch
Oct 1 '17 at 23:23
What doesfrom one directory up
mean?
â George Udosen
Oct 1 '17 at 23:25
If it's just a matter of visibility:alias ls='ls -a'
andshopt -s dotglob
(inbash
).
â Kusalananda
Oct 2 '17 at 5:45
If you're happy with one or several of the answers, upvote them. If one is solving your issue, accepting it would be the best way of saying "Thank You!" :-)
â Kusalananda
Oct 8 '17 at 15:40
Try it like this
rename -n 's/.//;' ../*
the -n
will see what happens without making any changes, then when your ok with it remove the -n
optionâ George Udosen
Oct 1 '17 at 23:05
Try it like this
rename -n 's/.//;' ../*
the -n
will see what happens without making any changes, then when your ok with it remove the -n
optionâ George Udosen
Oct 1 '17 at 23:05
I tried this command and its looking at the files above the directory I'm in not below? copied and pasted directly into putty
â Ortoch
Oct 1 '17 at 23:23
I tried this command and its looking at the files above the directory I'm in not below? copied and pasted directly into putty
â Ortoch
Oct 1 '17 at 23:23
What does
from one directory up
mean?â George Udosen
Oct 1 '17 at 23:25
What does
from one directory up
mean?â George Udosen
Oct 1 '17 at 23:25
If it's just a matter of visibility:
alias ls='ls -a'
and shopt -s dotglob
(in bash
).â Kusalananda
Oct 2 '17 at 5:45
If it's just a matter of visibility:
alias ls='ls -a'
and shopt -s dotglob
(in bash
).â Kusalananda
Oct 2 '17 at 5:45
If you're happy with one or several of the answers, upvote them. If one is solving your issue, accepting it would be the best way of saying "Thank You!" :-)
â Kusalananda
Oct 8 '17 at 15:40
If you're happy with one or several of the answers, upvote them. If one is solving your issue, accepting it would be the best way of saying "Thank You!" :-)
â Kusalananda
Oct 8 '17 at 15:40
add a comment |Â
6 Answers
6
active
oldest
votes
up vote
3
down vote
With GNU find
:
find /some/path -type f -name '.*' -execdir sh -c 'mv -i "$0" "./$0#./."' ;
With Perl rename
:
find /some/path -type f -name '.*' -exec prename -i -n 's!.*/K.!!' +
(remove -n
when you're happy with the results).
add a comment |Â
up vote
2
down vote
this is the line that fixed it all finally found the answer
find -mindepth 1 -depth -exec rename -n 's/.([^/]*$)/$1' +
This appliesrename
to files and directories alike, regardless of whether they actually need to be renamed or not.
â Kusalananda
Oct 2 '17 at 6:32
add a comment |Â
up vote
2
down vote
Just use find
together with a simple shell script for doing the renaming and checking that no existing file is overwritten:
find . -type f -name '.*'
-execdir sh -c '[ ! -e "$1#." ] && mv "$1" "$1#."' sh ';'
The -execdir
option will execute its argument inside the parent directory of the found name, and will be the base name (name without path) of the found name. This option is a widely implemented extension to standard
find
.
The sh -c
script will simply make sure that the desired name is not already taken, and then it will rename the file.
The $1#.
parameter substitution will take the value of $1
(the first command line argument of the sh -c
script, which is a filename) and remove the initial dot.
add a comment |Â
up vote
0
down vote
This will do what you want:
find . -iname ".*" -exec realpath ; | rename -n 's/.(.*)/$1/'
File structure:
.
âÂÂâÂÂâ game
âÂÂààâÂÂâÂÂâ .keie
âÂÂààâÂÂâÂÂâ .kjae
âÂÂààâÂÂâÂÂâ .ndhe
âÂÂààâÂÂâÂÂâ shame
âÂÂààâÂÂâÂÂâ .alwo
âÂÂààâÂÂâÂÂâ .asdjd
âÂÂààâÂÂâÂÂâ .kajd
âÂÂâÂÂâ .jsdsd
âÂÂâÂÂâ .lewe
âÂÂâÂÂâ .skdsd
Test run:
rename(/home/george/Documents/askubuntu/rename/down/.lewe, /home/george/Documents/askubuntu/rename/down/lewe)
rename(/home/george/Documents/askubuntu/rename/down/.jsdsd, /home/george/Documents/askubuntu/rename/down/jsdsd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.asdjd, /home/george/Documents/askubuntu/rename/down/game/shame/asdjd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.kajd, /home/george/Documents/askubuntu/rename/down/game/shame/kajd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.alwo, /home/george/Documents/askubuntu/rename/down/game/shame/alwo)
rename(/home/george/Documents/askubuntu/rename/down/game/.ndhe, /home/george/Documents/askubuntu/rename/down/game/ndhe)
rename(/home/george/Documents/askubuntu/rename/down/game/.keie, /home/george/Documents/askubuntu/rename/down/game/keie)
rename(/home/george/Documents/askubuntu/rename/down/game/.kjae, /home/george/Documents/askubuntu/rename/down/game/kjae)
rename(/home/george/Documents/askubuntu/rename/down/.skdsd, /home/george/Documents/askubuntu/rename/down/skdsd)
Results:
.
âÂÂâÂÂâ game
âÂÂààâÂÂâÂÂâ keie
âÂÂààâÂÂâÂÂâ kjae
âÂÂààâÂÂâÂÂâ ndhe
âÂÂààâÂÂâÂÂâ shame
âÂÂààâÂÂâÂÂâ alwo
âÂÂààâÂÂâÂÂâ asdjd
âÂÂààâÂÂâÂÂâ kajd
âÂÂâÂÂâ jsdsd
âÂÂâÂÂâ lewe
âÂÂâÂÂâ skdsd
Information:
realpath
: get the real path to file of interest
-n
: used to test run, remove when you're ready to rename the files.
same error as all the other answers which means you are all probably right but I'm doing something wrong
â Ortoch
Oct 1 '17 at 23:33
with -n the command looks like it will run perfectly here is output...find . -type f -iname ".*" -exec basename ; | rename -n 's/.//;' rename(.test3, test3) rename(.test1, test1) rename(.test2, test2) rename(.test3, test3) rename(.test1, test1)
â Ortoch
Oct 1 '17 at 23:34
remove the-n
when your ready to rename
â George Udosen
Oct 1 '17 at 23:34
yes without the -n I get this error for all 9 test files find . -type f -iname ".*" -exec basename ; | rename 's/.//;' Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory
â Ortoch
Oct 1 '17 at 23:36
I am in TEST running this command on TEST/T1/.test1 TEST/T1/.test2 TEST/T1/.test3 etc....
â Ortoch
Oct 1 '17 at 23:37
 |Â
show 2 more comments
up vote
-1
down vote
find . -type f -name .* -exec rename -n 's/.//;' +
same error as the above solution Can't rename ./T2/.test3 /T2/.test3: No such file or directory almost looks like its trying to rename the Directory or something?
â Ortoch
Oct 1 '17 at 23:22
1
That's becauserename
gets to see files as./path/foo
.
â Satà  Katsura
Oct 2 '17 at 3:25
add a comment |Â
up vote
-1
down vote
rename doesn't have a recursive option. If you want to rename the files in the current directory and all its subdirectories, put the following script in the parent directory and execute it.
#!/bin/bash
for i in `find . -name ".*"`
do
rename 's/.//' $i
done
Can't rename ./T2/.test3 /T2/.test3: No such file or directory got this error over and over in the test directory I'm playing with testing things out. Have 3 test directories with 3 test hidden files in each and all 9 files returned this string.
â Ortoch
Oct 1 '17 at 23:21
I don't understand why that code sample shouldn't work, but just for reference: use$()
instead ofback ticks
.
â ADDB
Oct 2 '17 at 17:42
add a comment |Â
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
With GNU find
:
find /some/path -type f -name '.*' -execdir sh -c 'mv -i "$0" "./$0#./."' ;
With Perl rename
:
find /some/path -type f -name '.*' -exec prename -i -n 's!.*/K.!!' +
(remove -n
when you're happy with the results).
add a comment |Â
up vote
3
down vote
With GNU find
:
find /some/path -type f -name '.*' -execdir sh -c 'mv -i "$0" "./$0#./."' ;
With Perl rename
:
find /some/path -type f -name '.*' -exec prename -i -n 's!.*/K.!!' +
(remove -n
when you're happy with the results).
add a comment |Â
up vote
3
down vote
up vote
3
down vote
With GNU find
:
find /some/path -type f -name '.*' -execdir sh -c 'mv -i "$0" "./$0#./."' ;
With Perl rename
:
find /some/path -type f -name '.*' -exec prename -i -n 's!.*/K.!!' +
(remove -n
when you're happy with the results).
With GNU find
:
find /some/path -type f -name '.*' -execdir sh -c 'mv -i "$0" "./$0#./."' ;
With Perl rename
:
find /some/path -type f -name '.*' -exec prename -i -n 's!.*/K.!!' +
(remove -n
when you're happy with the results).
edited Oct 2 '17 at 3:22
answered Oct 2 '17 at 3:15
Satà  Katsura
10.7k11533
10.7k11533
add a comment |Â
add a comment |Â
up vote
2
down vote
this is the line that fixed it all finally found the answer
find -mindepth 1 -depth -exec rename -n 's/.([^/]*$)/$1' +
This appliesrename
to files and directories alike, regardless of whether they actually need to be renamed or not.
â Kusalananda
Oct 2 '17 at 6:32
add a comment |Â
up vote
2
down vote
this is the line that fixed it all finally found the answer
find -mindepth 1 -depth -exec rename -n 's/.([^/]*$)/$1' +
This appliesrename
to files and directories alike, regardless of whether they actually need to be renamed or not.
â Kusalananda
Oct 2 '17 at 6:32
add a comment |Â
up vote
2
down vote
up vote
2
down vote
this is the line that fixed it all finally found the answer
find -mindepth 1 -depth -exec rename -n 's/.([^/]*$)/$1' +
this is the line that fixed it all finally found the answer
find -mindepth 1 -depth -exec rename -n 's/.([^/]*$)/$1' +
answered Oct 2 '17 at 0:04
Ortoch
313
313
This appliesrename
to files and directories alike, regardless of whether they actually need to be renamed or not.
â Kusalananda
Oct 2 '17 at 6:32
add a comment |Â
This appliesrename
to files and directories alike, regardless of whether they actually need to be renamed or not.
â Kusalananda
Oct 2 '17 at 6:32
This applies
rename
to files and directories alike, regardless of whether they actually need to be renamed or not.â Kusalananda
Oct 2 '17 at 6:32
This applies
rename
to files and directories alike, regardless of whether they actually need to be renamed or not.â Kusalananda
Oct 2 '17 at 6:32
add a comment |Â
up vote
2
down vote
Just use find
together with a simple shell script for doing the renaming and checking that no existing file is overwritten:
find . -type f -name '.*'
-execdir sh -c '[ ! -e "$1#." ] && mv "$1" "$1#."' sh ';'
The -execdir
option will execute its argument inside the parent directory of the found name, and will be the base name (name without path) of the found name. This option is a widely implemented extension to standard
find
.
The sh -c
script will simply make sure that the desired name is not already taken, and then it will rename the file.
The $1#.
parameter substitution will take the value of $1
(the first command line argument of the sh -c
script, which is a filename) and remove the initial dot.
add a comment |Â
up vote
2
down vote
Just use find
together with a simple shell script for doing the renaming and checking that no existing file is overwritten:
find . -type f -name '.*'
-execdir sh -c '[ ! -e "$1#." ] && mv "$1" "$1#."' sh ';'
The -execdir
option will execute its argument inside the parent directory of the found name, and will be the base name (name without path) of the found name. This option is a widely implemented extension to standard
find
.
The sh -c
script will simply make sure that the desired name is not already taken, and then it will rename the file.
The $1#.
parameter substitution will take the value of $1
(the first command line argument of the sh -c
script, which is a filename) and remove the initial dot.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Just use find
together with a simple shell script for doing the renaming and checking that no existing file is overwritten:
find . -type f -name '.*'
-execdir sh -c '[ ! -e "$1#." ] && mv "$1" "$1#."' sh ';'
The -execdir
option will execute its argument inside the parent directory of the found name, and will be the base name (name without path) of the found name. This option is a widely implemented extension to standard
find
.
The sh -c
script will simply make sure that the desired name is not already taken, and then it will rename the file.
The $1#.
parameter substitution will take the value of $1
(the first command line argument of the sh -c
script, which is a filename) and remove the initial dot.
Just use find
together with a simple shell script for doing the renaming and checking that no existing file is overwritten:
find . -type f -name '.*'
-execdir sh -c '[ ! -e "$1#." ] && mv "$1" "$1#."' sh ';'
The -execdir
option will execute its argument inside the parent directory of the found name, and will be the base name (name without path) of the found name. This option is a widely implemented extension to standard
find
.
The sh -c
script will simply make sure that the desired name is not already taken, and then it will rename the file.
The $1#.
parameter substitution will take the value of $1
(the first command line argument of the sh -c
script, which is a filename) and remove the initial dot.
edited Oct 8 '17 at 13:05
answered Oct 2 '17 at 6:23
Kusalananda
105k14209326
105k14209326
add a comment |Â
add a comment |Â
up vote
0
down vote
This will do what you want:
find . -iname ".*" -exec realpath ; | rename -n 's/.(.*)/$1/'
File structure:
.
âÂÂâÂÂâ game
âÂÂààâÂÂâÂÂâ .keie
âÂÂààâÂÂâÂÂâ .kjae
âÂÂààâÂÂâÂÂâ .ndhe
âÂÂààâÂÂâÂÂâ shame
âÂÂààâÂÂâÂÂâ .alwo
âÂÂààâÂÂâÂÂâ .asdjd
âÂÂààâÂÂâÂÂâ .kajd
âÂÂâÂÂâ .jsdsd
âÂÂâÂÂâ .lewe
âÂÂâÂÂâ .skdsd
Test run:
rename(/home/george/Documents/askubuntu/rename/down/.lewe, /home/george/Documents/askubuntu/rename/down/lewe)
rename(/home/george/Documents/askubuntu/rename/down/.jsdsd, /home/george/Documents/askubuntu/rename/down/jsdsd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.asdjd, /home/george/Documents/askubuntu/rename/down/game/shame/asdjd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.kajd, /home/george/Documents/askubuntu/rename/down/game/shame/kajd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.alwo, /home/george/Documents/askubuntu/rename/down/game/shame/alwo)
rename(/home/george/Documents/askubuntu/rename/down/game/.ndhe, /home/george/Documents/askubuntu/rename/down/game/ndhe)
rename(/home/george/Documents/askubuntu/rename/down/game/.keie, /home/george/Documents/askubuntu/rename/down/game/keie)
rename(/home/george/Documents/askubuntu/rename/down/game/.kjae, /home/george/Documents/askubuntu/rename/down/game/kjae)
rename(/home/george/Documents/askubuntu/rename/down/.skdsd, /home/george/Documents/askubuntu/rename/down/skdsd)
Results:
.
âÂÂâÂÂâ game
âÂÂààâÂÂâÂÂâ keie
âÂÂààâÂÂâÂÂâ kjae
âÂÂààâÂÂâÂÂâ ndhe
âÂÂààâÂÂâÂÂâ shame
âÂÂààâÂÂâÂÂâ alwo
âÂÂààâÂÂâÂÂâ asdjd
âÂÂààâÂÂâÂÂâ kajd
âÂÂâÂÂâ jsdsd
âÂÂâÂÂâ lewe
âÂÂâÂÂâ skdsd
Information:
realpath
: get the real path to file of interest
-n
: used to test run, remove when you're ready to rename the files.
same error as all the other answers which means you are all probably right but I'm doing something wrong
â Ortoch
Oct 1 '17 at 23:33
with -n the command looks like it will run perfectly here is output...find . -type f -iname ".*" -exec basename ; | rename -n 's/.//;' rename(.test3, test3) rename(.test1, test1) rename(.test2, test2) rename(.test3, test3) rename(.test1, test1)
â Ortoch
Oct 1 '17 at 23:34
remove the-n
when your ready to rename
â George Udosen
Oct 1 '17 at 23:34
yes without the -n I get this error for all 9 test files find . -type f -iname ".*" -exec basename ; | rename 's/.//;' Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory
â Ortoch
Oct 1 '17 at 23:36
I am in TEST running this command on TEST/T1/.test1 TEST/T1/.test2 TEST/T1/.test3 etc....
â Ortoch
Oct 1 '17 at 23:37
 |Â
show 2 more comments
up vote
0
down vote
This will do what you want:
find . -iname ".*" -exec realpath ; | rename -n 's/.(.*)/$1/'
File structure:
.
âÂÂâÂÂâ game
âÂÂààâÂÂâÂÂâ .keie
âÂÂààâÂÂâÂÂâ .kjae
âÂÂààâÂÂâÂÂâ .ndhe
âÂÂààâÂÂâÂÂâ shame
âÂÂààâÂÂâÂÂâ .alwo
âÂÂààâÂÂâÂÂâ .asdjd
âÂÂààâÂÂâÂÂâ .kajd
âÂÂâÂÂâ .jsdsd
âÂÂâÂÂâ .lewe
âÂÂâÂÂâ .skdsd
Test run:
rename(/home/george/Documents/askubuntu/rename/down/.lewe, /home/george/Documents/askubuntu/rename/down/lewe)
rename(/home/george/Documents/askubuntu/rename/down/.jsdsd, /home/george/Documents/askubuntu/rename/down/jsdsd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.asdjd, /home/george/Documents/askubuntu/rename/down/game/shame/asdjd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.kajd, /home/george/Documents/askubuntu/rename/down/game/shame/kajd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.alwo, /home/george/Documents/askubuntu/rename/down/game/shame/alwo)
rename(/home/george/Documents/askubuntu/rename/down/game/.ndhe, /home/george/Documents/askubuntu/rename/down/game/ndhe)
rename(/home/george/Documents/askubuntu/rename/down/game/.keie, /home/george/Documents/askubuntu/rename/down/game/keie)
rename(/home/george/Documents/askubuntu/rename/down/game/.kjae, /home/george/Documents/askubuntu/rename/down/game/kjae)
rename(/home/george/Documents/askubuntu/rename/down/.skdsd, /home/george/Documents/askubuntu/rename/down/skdsd)
Results:
.
âÂÂâÂÂâ game
âÂÂààâÂÂâÂÂâ keie
âÂÂààâÂÂâÂÂâ kjae
âÂÂààâÂÂâÂÂâ ndhe
âÂÂààâÂÂâÂÂâ shame
âÂÂààâÂÂâÂÂâ alwo
âÂÂààâÂÂâÂÂâ asdjd
âÂÂààâÂÂâÂÂâ kajd
âÂÂâÂÂâ jsdsd
âÂÂâÂÂâ lewe
âÂÂâÂÂâ skdsd
Information:
realpath
: get the real path to file of interest
-n
: used to test run, remove when you're ready to rename the files.
same error as all the other answers which means you are all probably right but I'm doing something wrong
â Ortoch
Oct 1 '17 at 23:33
with -n the command looks like it will run perfectly here is output...find . -type f -iname ".*" -exec basename ; | rename -n 's/.//;' rename(.test3, test3) rename(.test1, test1) rename(.test2, test2) rename(.test3, test3) rename(.test1, test1)
â Ortoch
Oct 1 '17 at 23:34
remove the-n
when your ready to rename
â George Udosen
Oct 1 '17 at 23:34
yes without the -n I get this error for all 9 test files find . -type f -iname ".*" -exec basename ; | rename 's/.//;' Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory
â Ortoch
Oct 1 '17 at 23:36
I am in TEST running this command on TEST/T1/.test1 TEST/T1/.test2 TEST/T1/.test3 etc....
â Ortoch
Oct 1 '17 at 23:37
 |Â
show 2 more comments
up vote
0
down vote
up vote
0
down vote
This will do what you want:
find . -iname ".*" -exec realpath ; | rename -n 's/.(.*)/$1/'
File structure:
.
âÂÂâÂÂâ game
âÂÂààâÂÂâÂÂâ .keie
âÂÂààâÂÂâÂÂâ .kjae
âÂÂààâÂÂâÂÂâ .ndhe
âÂÂààâÂÂâÂÂâ shame
âÂÂààâÂÂâÂÂâ .alwo
âÂÂààâÂÂâÂÂâ .asdjd
âÂÂààâÂÂâÂÂâ .kajd
âÂÂâÂÂâ .jsdsd
âÂÂâÂÂâ .lewe
âÂÂâÂÂâ .skdsd
Test run:
rename(/home/george/Documents/askubuntu/rename/down/.lewe, /home/george/Documents/askubuntu/rename/down/lewe)
rename(/home/george/Documents/askubuntu/rename/down/.jsdsd, /home/george/Documents/askubuntu/rename/down/jsdsd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.asdjd, /home/george/Documents/askubuntu/rename/down/game/shame/asdjd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.kajd, /home/george/Documents/askubuntu/rename/down/game/shame/kajd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.alwo, /home/george/Documents/askubuntu/rename/down/game/shame/alwo)
rename(/home/george/Documents/askubuntu/rename/down/game/.ndhe, /home/george/Documents/askubuntu/rename/down/game/ndhe)
rename(/home/george/Documents/askubuntu/rename/down/game/.keie, /home/george/Documents/askubuntu/rename/down/game/keie)
rename(/home/george/Documents/askubuntu/rename/down/game/.kjae, /home/george/Documents/askubuntu/rename/down/game/kjae)
rename(/home/george/Documents/askubuntu/rename/down/.skdsd, /home/george/Documents/askubuntu/rename/down/skdsd)
Results:
.
âÂÂâÂÂâ game
âÂÂààâÂÂâÂÂâ keie
âÂÂààâÂÂâÂÂâ kjae
âÂÂààâÂÂâÂÂâ ndhe
âÂÂààâÂÂâÂÂâ shame
âÂÂààâÂÂâÂÂâ alwo
âÂÂààâÂÂâÂÂâ asdjd
âÂÂààâÂÂâÂÂâ kajd
âÂÂâÂÂâ jsdsd
âÂÂâÂÂâ lewe
âÂÂâÂÂâ skdsd
Information:
realpath
: get the real path to file of interest
-n
: used to test run, remove when you're ready to rename the files.
This will do what you want:
find . -iname ".*" -exec realpath ; | rename -n 's/.(.*)/$1/'
File structure:
.
âÂÂâÂÂâ game
âÂÂààâÂÂâÂÂâ .keie
âÂÂààâÂÂâÂÂâ .kjae
âÂÂààâÂÂâÂÂâ .ndhe
âÂÂààâÂÂâÂÂâ shame
âÂÂààâÂÂâÂÂâ .alwo
âÂÂààâÂÂâÂÂâ .asdjd
âÂÂààâÂÂâÂÂâ .kajd
âÂÂâÂÂâ .jsdsd
âÂÂâÂÂâ .lewe
âÂÂâÂÂâ .skdsd
Test run:
rename(/home/george/Documents/askubuntu/rename/down/.lewe, /home/george/Documents/askubuntu/rename/down/lewe)
rename(/home/george/Documents/askubuntu/rename/down/.jsdsd, /home/george/Documents/askubuntu/rename/down/jsdsd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.asdjd, /home/george/Documents/askubuntu/rename/down/game/shame/asdjd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.kajd, /home/george/Documents/askubuntu/rename/down/game/shame/kajd)
rename(/home/george/Documents/askubuntu/rename/down/game/shame/.alwo, /home/george/Documents/askubuntu/rename/down/game/shame/alwo)
rename(/home/george/Documents/askubuntu/rename/down/game/.ndhe, /home/george/Documents/askubuntu/rename/down/game/ndhe)
rename(/home/george/Documents/askubuntu/rename/down/game/.keie, /home/george/Documents/askubuntu/rename/down/game/keie)
rename(/home/george/Documents/askubuntu/rename/down/game/.kjae, /home/george/Documents/askubuntu/rename/down/game/kjae)
rename(/home/george/Documents/askubuntu/rename/down/.skdsd, /home/george/Documents/askubuntu/rename/down/skdsd)
Results:
.
âÂÂâÂÂâ game
âÂÂààâÂÂâÂÂâ keie
âÂÂààâÂÂâÂÂâ kjae
âÂÂààâÂÂâÂÂâ ndhe
âÂÂààâÂÂâÂÂâ shame
âÂÂààâÂÂâÂÂâ alwo
âÂÂààâÂÂâÂÂâ asdjd
âÂÂààâÂÂâÂÂâ kajd
âÂÂâÂÂâ jsdsd
âÂÂâÂÂâ lewe
âÂÂâÂÂâ skdsd
Information:
realpath
: get the real path to file of interest
-n
: used to test run, remove when you're ready to rename the files.
edited Oct 2 '17 at 8:22
answered Oct 1 '17 at 23:31
George Udosen
1,112318
1,112318
same error as all the other answers which means you are all probably right but I'm doing something wrong
â Ortoch
Oct 1 '17 at 23:33
with -n the command looks like it will run perfectly here is output...find . -type f -iname ".*" -exec basename ; | rename -n 's/.//;' rename(.test3, test3) rename(.test1, test1) rename(.test2, test2) rename(.test3, test3) rename(.test1, test1)
â Ortoch
Oct 1 '17 at 23:34
remove the-n
when your ready to rename
â George Udosen
Oct 1 '17 at 23:34
yes without the -n I get this error for all 9 test files find . -type f -iname ".*" -exec basename ; | rename 's/.//;' Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory
â Ortoch
Oct 1 '17 at 23:36
I am in TEST running this command on TEST/T1/.test1 TEST/T1/.test2 TEST/T1/.test3 etc....
â Ortoch
Oct 1 '17 at 23:37
 |Â
show 2 more comments
same error as all the other answers which means you are all probably right but I'm doing something wrong
â Ortoch
Oct 1 '17 at 23:33
with -n the command looks like it will run perfectly here is output...find . -type f -iname ".*" -exec basename ; | rename -n 's/.//;' rename(.test3, test3) rename(.test1, test1) rename(.test2, test2) rename(.test3, test3) rename(.test1, test1)
â Ortoch
Oct 1 '17 at 23:34
remove the-n
when your ready to rename
â George Udosen
Oct 1 '17 at 23:34
yes without the -n I get this error for all 9 test files find . -type f -iname ".*" -exec basename ; | rename 's/.//;' Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory
â Ortoch
Oct 1 '17 at 23:36
I am in TEST running this command on TEST/T1/.test1 TEST/T1/.test2 TEST/T1/.test3 etc....
â Ortoch
Oct 1 '17 at 23:37
same error as all the other answers which means you are all probably right but I'm doing something wrong
â Ortoch
Oct 1 '17 at 23:33
same error as all the other answers which means you are all probably right but I'm doing something wrong
â Ortoch
Oct 1 '17 at 23:33
with -n the command looks like it will run perfectly here is output...find . -type f -iname ".*" -exec basename ; | rename -n 's/.//;' rename(.test3, test3) rename(.test1, test1) rename(.test2, test2) rename(.test3, test3) rename(.test1, test1)
â Ortoch
Oct 1 '17 at 23:34
with -n the command looks like it will run perfectly here is output...find . -type f -iname ".*" -exec basename ; | rename -n 's/.//;' rename(.test3, test3) rename(.test1, test1) rename(.test2, test2) rename(.test3, test3) rename(.test1, test1)
â Ortoch
Oct 1 '17 at 23:34
remove the
-n
when your ready to renameâ George Udosen
Oct 1 '17 at 23:34
remove the
-n
when your ready to renameâ George Udosen
Oct 1 '17 at 23:34
yes without the -n I get this error for all 9 test files find . -type f -iname ".*" -exec basename ; | rename 's/.//;' Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory
â Ortoch
Oct 1 '17 at 23:36
yes without the -n I get this error for all 9 test files find . -type f -iname ".*" -exec basename ; | rename 's/.//;' Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory Can't rename .test3 test3: No such file or directory Can't rename .test1 test1: No such file or directory Can't rename .test2 test2: No such file or directory
â Ortoch
Oct 1 '17 at 23:36
I am in TEST running this command on TEST/T1/.test1 TEST/T1/.test2 TEST/T1/.test3 etc....
â Ortoch
Oct 1 '17 at 23:37
I am in TEST running this command on TEST/T1/.test1 TEST/T1/.test2 TEST/T1/.test3 etc....
â Ortoch
Oct 1 '17 at 23:37
 |Â
show 2 more comments
up vote
-1
down vote
find . -type f -name .* -exec rename -n 's/.//;' +
same error as the above solution Can't rename ./T2/.test3 /T2/.test3: No such file or directory almost looks like its trying to rename the Directory or something?
â Ortoch
Oct 1 '17 at 23:22
1
That's becauserename
gets to see files as./path/foo
.
â Satà  Katsura
Oct 2 '17 at 3:25
add a comment |Â
up vote
-1
down vote
find . -type f -name .* -exec rename -n 's/.//;' +
same error as the above solution Can't rename ./T2/.test3 /T2/.test3: No such file or directory almost looks like its trying to rename the Directory or something?
â Ortoch
Oct 1 '17 at 23:22
1
That's becauserename
gets to see files as./path/foo
.
â Satà  Katsura
Oct 2 '17 at 3:25
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
find . -type f -name .* -exec rename -n 's/.//;' +
find . -type f -name .* -exec rename -n 's/.//;' +
answered Oct 1 '17 at 23:14
Hauke Laging
53.7k1282130
53.7k1282130
same error as the above solution Can't rename ./T2/.test3 /T2/.test3: No such file or directory almost looks like its trying to rename the Directory or something?
â Ortoch
Oct 1 '17 at 23:22
1
That's becauserename
gets to see files as./path/foo
.
â Satà  Katsura
Oct 2 '17 at 3:25
add a comment |Â
same error as the above solution Can't rename ./T2/.test3 /T2/.test3: No such file or directory almost looks like its trying to rename the Directory or something?
â Ortoch
Oct 1 '17 at 23:22
1
That's becauserename
gets to see files as./path/foo
.
â Satà  Katsura
Oct 2 '17 at 3:25
same error as the above solution Can't rename ./T2/.test3 /T2/.test3: No such file or directory almost looks like its trying to rename the Directory or something?
â Ortoch
Oct 1 '17 at 23:22
same error as the above solution Can't rename ./T2/.test3 /T2/.test3: No such file or directory almost looks like its trying to rename the Directory or something?
â Ortoch
Oct 1 '17 at 23:22
1
1
That's because
rename
gets to see files as ./path/foo
.â Satà  Katsura
Oct 2 '17 at 3:25
That's because
rename
gets to see files as ./path/foo
.â Satà  Katsura
Oct 2 '17 at 3:25
add a comment |Â
up vote
-1
down vote
rename doesn't have a recursive option. If you want to rename the files in the current directory and all its subdirectories, put the following script in the parent directory and execute it.
#!/bin/bash
for i in `find . -name ".*"`
do
rename 's/.//' $i
done
Can't rename ./T2/.test3 /T2/.test3: No such file or directory got this error over and over in the test directory I'm playing with testing things out. Have 3 test directories with 3 test hidden files in each and all 9 files returned this string.
â Ortoch
Oct 1 '17 at 23:21
I don't understand why that code sample shouldn't work, but just for reference: use$()
instead ofback ticks
.
â ADDB
Oct 2 '17 at 17:42
add a comment |Â
up vote
-1
down vote
rename doesn't have a recursive option. If you want to rename the files in the current directory and all its subdirectories, put the following script in the parent directory and execute it.
#!/bin/bash
for i in `find . -name ".*"`
do
rename 's/.//' $i
done
Can't rename ./T2/.test3 /T2/.test3: No such file or directory got this error over and over in the test directory I'm playing with testing things out. Have 3 test directories with 3 test hidden files in each and all 9 files returned this string.
â Ortoch
Oct 1 '17 at 23:21
I don't understand why that code sample shouldn't work, but just for reference: use$()
instead ofback ticks
.
â ADDB
Oct 2 '17 at 17:42
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
rename doesn't have a recursive option. If you want to rename the files in the current directory and all its subdirectories, put the following script in the parent directory and execute it.
#!/bin/bash
for i in `find . -name ".*"`
do
rename 's/.//' $i
done
rename doesn't have a recursive option. If you want to rename the files in the current directory and all its subdirectories, put the following script in the parent directory and execute it.
#!/bin/bash
for i in `find . -name ".*"`
do
rename 's/.//' $i
done
answered Oct 1 '17 at 23:17
Garnet
263
263
Can't rename ./T2/.test3 /T2/.test3: No such file or directory got this error over and over in the test directory I'm playing with testing things out. Have 3 test directories with 3 test hidden files in each and all 9 files returned this string.
â Ortoch
Oct 1 '17 at 23:21
I don't understand why that code sample shouldn't work, but just for reference: use$()
instead ofback ticks
.
â ADDB
Oct 2 '17 at 17:42
add a comment |Â
Can't rename ./T2/.test3 /T2/.test3: No such file or directory got this error over and over in the test directory I'm playing with testing things out. Have 3 test directories with 3 test hidden files in each and all 9 files returned this string.
â Ortoch
Oct 1 '17 at 23:21
I don't understand why that code sample shouldn't work, but just for reference: use$()
instead ofback ticks
.
â ADDB
Oct 2 '17 at 17:42
Can't rename ./T2/.test3 /T2/.test3: No such file or directory got this error over and over in the test directory I'm playing with testing things out. Have 3 test directories with 3 test hidden files in each and all 9 files returned this string.
â Ortoch
Oct 1 '17 at 23:21
Can't rename ./T2/.test3 /T2/.test3: No such file or directory got this error over and over in the test directory I'm playing with testing things out. Have 3 test directories with 3 test hidden files in each and all 9 files returned this string.
â Ortoch
Oct 1 '17 at 23:21
I don't understand why that code sample shouldn't work, but just for reference: use
$()
instead of back ticks
.â ADDB
Oct 2 '17 at 17:42
I don't understand why that code sample shouldn't work, but just for reference: use
$()
instead of back ticks
.â ADDB
Oct 2 '17 at 17:42
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f395530%2funix-how-to-change-all-hidden-files-to-visible-in-a-multiple-sub-directories%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Try it like this
rename -n 's/.//;' ../*
the-n
will see what happens without making any changes, then when your ok with it remove the-n
optionâ George Udosen
Oct 1 '17 at 23:05
I tried this command and its looking at the files above the directory I'm in not below? copied and pasted directly into putty
â Ortoch
Oct 1 '17 at 23:23
What does
from one directory up
mean?â George Udosen
Oct 1 '17 at 23:25
If it's just a matter of visibility:
alias ls='ls -a'
andshopt -s dotglob
(inbash
).â Kusalananda
Oct 2 '17 at 5:45
If you're happy with one or several of the answers, upvote them. If one is solving your issue, accepting it would be the best way of saying "Thank You!" :-)
â Kusalananda
Oct 8 '17 at 15:40