Page 1 of 1
Creating folders from files
Posted: 04 Jun 2021 13:02
by mpratt
I have a large movie collection and want to put each movie into its own folder. Is it possible to create a folder for each one and place the file in the folder? Thanks in advance for any direction.
Re: Creating folders from files
Posted: 04 Jun 2021 13:06
by highend
Code: Select all
C:\movies\Latest movie 2021.mp4 -> C:\movies\Latest movie 2021\Latest movie 2021.mp4
Or how is it supposed to work?
Re: Creating folders from files
Posted: 04 Jun 2021 13:58
by mpratt
I am really new at this. Could you expand for a beginner. I understand the concept, just need help in execution. Thanks.
Re: Creating folders from files
Posted: 04 Jun 2021 14:23
by highend
Expand... what?
You didn't give an example so I've posted one and now I'd like to know if this is the way it should be done.
If yes, selecting all files (manually) and executing a small script would do it:
Code: Select all
foreach($item, <get SelectedItemsPathNames |>, , "e") {
if (exists($item) == 2) { continue; }
moveto gpc($item, "path") . "\" . gpc($item, "base"), $item, , 2, 2;
}
Re: Creating folders from files
Posted: 05 Jun 2021 18:23
by mpratt
Here is an example. I have a large number of files (movies, TV Shows, videos). The database program(s) (Plex & Kodi) that wants to use the files would like each file in a separate folder to establish a common format. I would like to be able to do the files I currently have as well as new ones I acquire. (Please keep in mind, I am a beginner and still learning. )
Current
C:/media/Videos
Video01 (2020).avi
Video02 (1986).avi
Video03 (2002).avi
Would Like
C:/media/Videos/
C:/media/Videos/Video01 (2020)/Video01 (2020).avi
C:/media/Videos/Video02 (2020)/Video02 (2020).avi
C:/media/Videos/Video03 (2020)/Video03 (2020).avi
Thanks in advance.
Re: Creating folders from files
Posted: 05 Jun 2021 18:52
by highend
Why would these two files
Code: Select all
Video02 (1986).avi
Video03 (2002).avi
end as
Code: Select all
C:/media/Videos/Video02 (2020)/Video02 (2020).avi
C:/media/Videos/Video03 (2020)/Video03 (2020).avi
?
Re: Creating folders from files
Posted: 06 Jun 2021 01:30
by mpratt
Sorry my bad typing. I need the original file name be the name of the new folder and the file inserted in the folder. Thanks.
Re: Creating folders from files
Posted: 06 Jun 2021 08:10
by highend
The script in
viewtopic.php?p=188068#p188068
handles this just fine...
Re: Creating folders from files
Posted: 06 Jun 2021 13:34
by XYBill
I had the exact same question and came up with this solution. This little script works with Explorer as well as XYPlorer.
Now all I need to do is right click on any file and select "Create Folder and Move" from context menu and the folder gets created based on the file name and the file gets moved into that folder.
You can also select multiple files and the script creates multiple folders and moves the files.
Steps:
1: Right click on the C drive and select "Create New Sub Folder Here" and name it "Send to Scripts". (without the quotes)
2: Using Notepad, create a "Send to Create Folder and Move.bat" file in 2: c:\Send to Scripts folder that contains:
(rename .txt to .bat after saving file)
(Copy the below text into the Notepad and save as "Send to Create Folder and Move.bat")
@echo off
set "Dest=%~dpn1"
cd /d "%~dp1"
if exist "%Dest%" goto :eof
mkdir "%Dest%" >NUL 2>&1
for %%A in (%*) do (
move %%A "%Dest%"
) >NUL 2>&1
echo "DONE!"
exit /b
3: Using Notepad, create a "Send to Create Folder and Move.reg" file in c:\Send to Scripts folder that contains:
(rename .reg to .bat after saving file)
(Copy the below text into the Notepad and save as "Send to Create Folder and Move.reg")
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Create Folder and Move]
"Icon"="%SystemRoot%\\System32\\shell32.dll,4"
[HKEY_CLASSES_ROOT\*\shell\Create Folder and Move\command]
@="\"C:\\Send to Scripts\\Send to Create folder and move.bat\" \"%1\""
4: Once the 2 files are created ( .bat and .reg), Right click on the .reg files and select "Merge"
5: You are now ready to start using the script.
Enjoy
Re: Creating folders from files
Posted: 06 Jun 2021 16:36
by RalphM
Hi XYBill
Welcome to the forum.
What did you do all these years since you joined this forum in 2013 until you finally felt compelled to add your voice to this thread?
Re: Creating folders from files
Posted: 06 Jun 2021 16:52
by Horst
Hi XYBill
I find it a rather strange idea to create such a folder in the root of drive C:
Why not making a top level entry like Tools and sub-dirs or files below this.