Sign in to follow this  
Followers 0
kizer

Create a Folder from a FileName and move File into it

3 posts in this topic

For instance I'd like to do something of the sort. 

 

From Some Folder lets Say

 

/mnt/Cache/2BeProcessed/

Transformers.mkv

Aliens.mkv

KingKong.mkv

SuperMan.mkv

 

into:

 

Movies/

Transformers/Transfomers.mkv

Aliens/Aliens.mkv

KingKong/KingKong.mkv

Superman/Superman.mkv

 

I'd like to be able to execute a script or click a button and move a group of files into their prospective folder and place said folders in a final destination. I guess this would work great from Cron or from user.scripts just as well. Actually I think it would be a bit cleaner to run it from user.scripts honestly. 

 

Please and Thank you of course. I tried a few times to find some code that would execute this, but oddly I can never get the loop to work right or for it to pick a folder opposed to executing it directly from the folder the script sits in along with the files. 

0

Share this post


Link to post
Share on other sites

From Windows.  I have it saved from years ago, but test before use on sample directories.  Not sure what its talking about why it would be a risk on network shares

REM file2folder.bat
REM Written by Jon from theHTPC.net
REM Ensure file attribute is set to hidden.  Very important!
REM Place in folder where your media files are located.
REM Use at own risk on network shares.  Bad things have happened.
REM Run the batch file and all of your files will be moved into newly
REM created folders of the same name!
REM This script is NOT recursive.  Must be run on all directories containing
REM media files.
REM NOT recommended for TV series episodes!
REM Visit www.theHTPC.net for HTPC-related news, tips, plugins and more!

REM ---BEGIN SCRIPT---

@echo off
for %%a in (*.*) do (
md "%%~na" 2>nul
move "%%a" "%%~na"
)
pause

REM ----END SCRIPT----

 

0

Share this post


Link to post
Share on other sites

Thanks Squid. I currently have something more or less of the same sorts. I was trying to find a unRAID version of it so I could pull my windows box out of the mix now and then, but I guess I'll continue to use what I have until I find something that can run via linux. 

 

I attached what I'm currently running in windows. Its Basically a VBS file I found on the net long time ago. Kinda me freaked me out trusting a .VBS file. Lol

 

dim objFSO, objFolder, b, c, newfolder
dim colFiles, source, destination

source = "\\192.168.1.127\cache\ZZZZZ\"
destination = "\\192.168.1.127\cache\Travel\"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(source)
Set colFiles = objFolder.Files

For Each objFile In colFiles

b = objFSO.GetBaseName (objFile.Name) 'get 'text' instead of 'text.txt'
c = objFSO.CreateFolder(source & b) 'create folder of same filename in same location as source directory
objFile.Move c & "\" & objFile.Name 'move file to within new folder

set newfolder = objFSO.GetFolder(source & b)
newfolder.Move(destination)

Next

 

createfolder.vbs

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

Copyright © 2005-2017 Lime Technology, Inc. unRAID® is a registered trademark of Lime Technology, Inc.