RockDawg Posted July 24, 2007 Share Posted July 24, 2007 I am looking for an automated way to move the contents of a subdirectory to the parent directory and then delete the resulting empty subfolder. For example: My movie files are currently stored: Twister\VIDEO_TS\files. I would like to change them all to Twister\files I dread the thought of manually cutting and pasting for each movie (I have ~570). Just wondering if there is some quick and easy script or something that would accomplish this unattended. Quote Link to comment
BillK Posted July 26, 2007 Share Posted July 26, 2007 RockDawg, I'm no Linux expert, but here's an idea (I haven't tried it, so highly suggest you experiment with a dummy file & directories): 1. Telnet into your unRAID server. 2. Use the "&" command to a command in the background (i.e., the system should immediately return control to you, allowing you to do other things) in combo with... 3. Use the "mv" command to move your files within the unRAID server (see below) &mv /mnt/disk1/Twister/VIDEO_TS/files /mnt/disk2/Twister/files (you may need to create the Twister\files directory first). Quote Link to comment
Billped Posted July 26, 2007 Share Posted July 26, 2007 I haven't looked, but is PERL enabled via Unraid? I would have to crack open a book to remember how to do what the OP wants, but that would be a lot faster than doing 570 individual mv commands. Bill Quote Link to comment
RobJ Posted July 26, 2007 Share Posted July 26, 2007 I would use a batch file or script, something like this pseudocode: for %dir in ( * ) if exist %dir\VIDEO_TS\*.* echo %dir move %dir\VIDEO_TS\*.* %dir del %dir\VIDEO_TS It will take a lot longer to work out the syntactical details, and test it, than it will take to run this script/batch, perhaps less then 10 minutes to run. I would test it on a temp folder containing copies of 3 movie folders. Since you are only moving directory entries, not moving or copying files, I think it would be better to do everything on a Windows machine, because you will have more choices available in scripting or batching tools. I'm afraid my batch file skills are too rusty to help. Quote Link to comment
RockDawg Posted July 29, 2007 Author Share Posted July 29, 2007 RobJ - not exactly sure how to run that. Quote Link to comment
RobJ Posted July 30, 2007 Share Posted July 30, 2007 I was hoping that one of the expert scripters here would provide a script or batch file for you, or that you had a favorite batch or scripting tool. I've created many batch files, some quite complex, but that was in my DOS days, prior to Long File Names. Batch files have changed some since then, and I'm very rusty. If I get to it, I'll try to come up with something, doesn't look very hard. I'm lazily still hoping someone else will though! Quote Link to comment
RockDawg Posted July 30, 2007 Author Share Posted July 30, 2007 I see. Don't bother yourself with it then. I've never done any scripting or created a batch file and I don't want people to have to research it for me. I just thought it might be easy enought that someone would know off hand how to do it. Thanks anyway. Quote Link to comment
montery Posted August 26, 2007 Share Posted August 26, 2007 Sorry, don't mean to hijack a thread here, but how about moving files from your inbound box (the computer that you use to get your source files) to your Unraid server? I use Azereus and I can move files from one directory to another after the download is complete, but I'm trying to think of a way to have them moved over to the server after the upload ratio has returned to 1. Any ideas? Or should I wait for the version of unraid that includes file management under the covers? Thanks. Quote Link to comment
Arby Posted April 16, 2021 Share Posted April 16, 2021 (edited) I'd really appreciate if a script was made to do exactly this and if you didn't know the name of the subfolder, in OP's example "VIDEO_TS" is not known say, because you will not know what you will download in the future. Edit: I have found a script that works: #!/bin/bash find /mnt/user/hms/Materials/Books/Mainfiles -type f -exec mv --backup=numbered -t /mnt/user/hms/Materials/Books/Mainfiles {} + Edited April 18, 2021 by Arby Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.