A script that renames a folder to an integer after some other steps...
I'm not too sure how to explain what I'm trying to do. I'll eventually open up some sed and awk books, but at the moment, I don't know how to do what I want.
prestart: mount /dev/something1 1. Rename */foldername/ to an integer stored in a file. 2. Pull integer from file. 3. If integer in file = 0, which is the default for just beginning, then rename folder to */1/ 4. Store proof of integer change in file. Integer in file turns into 1. 5. Transfer files from */1/ to external medium 6. Delete */1/ 7. umount /dev/something1 new start: 1. mount /dev/something1 2. Rename */foldername/ to an integer stored in the previously mentioned file 3. Since stored integer = 1, rename folder to */2/ 4. Store proof of integer change in file. Integer in file turns into 2. 5. Transfer files from */2/ to external medium 6. Delete */2/ 7. umount /dev/something1 You've got the idea, I guess. */foldername/ is never a number. It uses letters. The integer goes up +1 each time. |
You've explained it quite well!
We won't do the work for you, of course, but here's a good place to raise any specific questions. My question for you is: What does your script look like so far? |
Quote:
#!/bin/sh # # Filename: super-transfer.sh # # =========================== # mount devices # =========================== # # mkdir /mnt/abc1/ mkdir /mnt/xyz/ mount /dev/abc1 /mnt/abc1/ mount /dev/xyz /mnt/xyz/ # # ====================================== # Pull, examine, and create new integer # * Scripts are located in home directory # ====================================== # * folder-renaming.x naturally contains a 0; it was a manually created file. # awk '{ print expr $1 + 1 > "folder-renaming.x"}' folder-renaming.x # # # ====================================== # Change variable of saving folder # ====================================== # # # I don't have full understanding of sed. # I was playing with sed, but I can't figure out how to # assign a variable to something part of the folder-directory system # Example: /information/$variable/ # I figure I would do something like this: # #----------------------------------------------------------- sed '/$variable/s//$1/g' # I know this isn't right at all #----------------------------------------------------------- # # # $1 would be from folder-renaming.x # and $variable would be from the script that saves stuff # #________________________________________________________________ Quote:
#________________________________________________________________ #________________________________________________________________ #________________________________________________________________ # # We are now looking at super-transfer.sh again # # # =========================== # delete folder # =========================== # rmdir /mnt/xyz/folder/ # # # =========================== # unmount devices # =========================== # # umount /dev/abc1 /mnt/abc1/ umount /dev/xyz /mnt/xyz/ # # # exit 0 |
Quoth Cyberman:
Code:
sed '/$variable/s//$1/g' # I know this isn't right at all Then run the script, feeding it data by hand and watching it not work. Come back here with the tiny script, what you fed it, what you got as output, and what you wanted. That work for you? (grin) |
You're not very helpful. You might as well not respond. (^)--o
My finger goes out to you for acting like Socrates. You could have at least given a weblink, but I figure you're just trying to bring your posts number up. Screw it. I'll buy the code. I have more money than time for this b.s. |
If you have more money than time, I can understand.
At seemingly regular intervals, I answer requests for solutions to problems by leading the original poster to solve such problems on his own. It's regrettable that this approach is not the best one for you, but if you can "buy the code", at least your problem is solved. Best wishes. |
All times are GMT -5. The time now is 08:25 PM. |