Thank you
Well, actually I was wrong with that file path.. my bad. But when I correct the file path, I do find a lot of files, and they are the files I would like corrected.
However, when I enter in the code below, I get a long line of lines of files that say for example
mv: can't rename 'Reports/1234/6:27:16': No such file or directory
Code: Select all
[/share/Reports] # for f in $(find /share/Reports/ -name "*:*"); do mv "$f" ${f/:/_}; done
As for isolating one file, I will pick the one I just used for that example. /share/Reports/Cust PDF Reports/1234/6:27:16
So when I enter
Code: Select all
[/share/Reports/Cust PDF Reports/1234] # find . -name "*:*"
I get all the files (in this folder) that I am looking for. The obvious issue is that when I type in the code from before, I get "Reports/acct number/file date" and not the correct value which would have been "Reports/Cust PDF Reports/acct number/file date", and there are a lot more account numbers to deal with so I am hoping to be able to set up a more general case command to enter. But for now I'm ignoring that and am going to work through what you asked me to.
In this example I get the files listed as follows
./2:22:2017
./4:26:18
./6:27:16
./Essen 5:31:16
Then I entered in
Code: Select all
[/share/Reports/Cust PDF Reports/1234] # for f in $(find . -name "*:*"); do mv "$f" ${f/:/_}; done
and it worked! sort of..
1) as you can see there is a space in one of the file names, which is fine as far as I am concerned, however I got two errors that it cant rename a file called "./Essen" and that it cannot rename a file named "./5:31:16" "No such file or directory". and I am unsure how to circumvent this, I believe I would have to put quotation marks around the file name, but am not sure where to do that with all the variable stuff that is unfamiliar to me so far.
2) When I use the find command now for this directory I get the following. (at this point i could just use ls as these are the only files in this directory anyway, but new skills are fun to practice.)
Code: Select all
[/share/Reports/Cust PDF Reports/1234] # find . -name "*:*"
./2_22:2017
./4_26:18
./6_27:16
./Essen 5:31:16
PROGRESS!!
Now out of curiosity I ran the following code again
Code: Select all
[/share/Reports/Cust PDF Reports/1234] # for f in $(find . -name "*:*"); do mv "$f" ${f/:/_}; done
and it worked.. again! Other than that file with the space in it, now nothing shows up for the find function but that file, and when I do ls. its exactly what I was looking for.
2_22_2017
4_26_18
6_27_16
Essen 5:31:16
So first off, thank you so much!! I have learned a lot in this exercise with your help! I was, however, hoping that you could answer some follow up questions that I encountered along the way.
1) getting a method that can reliably find all files/folders within a larger directory(/share/Reports/Cust PDF Reports/) that includes sub directories(individual account numbers, all 4 digit) which in turn contain the file/folder that I want to change the name of. I only have a couple hundred, so it would not be the worst thing in the world to do it manually for each account number if its what I need to do.
2) file names with spaces, help please
3) is there a way to get this to run lets say 5 times on its own in case there are many colons in one name? This is just for my own curiosity in learning terminal, I am more than willing to hit up and enter 5 times
as for 1, I attempted just going for this and still got all the "no such file or directory" stuff from before.
Code: Select all
[/share/Reports/Cust PDF Reports] # for f in $(find . -name "*:*"); do mv "$f" ${f/:/_}; done