Creating folders from files

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
mpratt
Posts: 4
Joined: 04 Jun 2021 12:58

Creating folders from files

Post 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.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Creating folders from files

Post 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?
One of my scripts helped you out? Please donate via Paypal

mpratt
Posts: 4
Joined: 04 Jun 2021 12:58

Re: Creating folders from files

Post by mpratt »

I am really new at this. Could you expand for a beginner. I understand the concept, just need help in execution. Thanks.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Creating folders from files

Post 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;
    }
One of my scripts helped you out? Please donate via Paypal

mpratt
Posts: 4
Joined: 04 Jun 2021 12:58

Re: Creating folders from files

Post 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.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Creating folders from files

Post 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
?
One of my scripts helped you out? Please donate via Paypal

mpratt
Posts: 4
Joined: 04 Jun 2021 12:58

Re: Creating folders from files

Post 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.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Creating folders from files

Post by highend »

The script in viewtopic.php?p=188068#p188068
handles this just fine...
One of my scripts helped you out? Please donate via Paypal

XYBill
Posts: 1
Joined: 16 Jan 2013 03:33

Re: Creating folders from files

Post 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

RalphM
Posts: 1932
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Creating folders from files

Post 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?
Ralph :)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)

Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Creating folders from files

Post 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.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

Post Reply