Moving files into folders

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

QT-Pro
Silver Member
Silver Member
Posts: 176
Joined: 2007 Jul 12, 15:55

Moving files into folders

Post by QT-Pro »

I am using v2.5.0.4 still because I didn't see the need to upgrade to v3.0.
I have a folder filled with 100's of files and need to create a separate folder for each individual file. That would take too long on a one-by-one basis. I know a program called 'File 2 Folder' that can do this in a single click but when I installed it my antivirus blocked the installation claiming it contained malware. x2 is so customizable that I was wondering if there is some way I can make x2 achieve the same task, and if so, how?

If x2 cannot do it, does anyone know of any other stand alone programs that can achieve this please?
QT-Pro
Silver Member
Silver Member
Posts: 176
Joined: 2007 Jul 12, 15:55

Re: Moving files into folders

Post by QT-Pro »

Update: I found a snippet of code that you can save as a text file and once saved, convert to a .bat extension.

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

Copy that script to the folder where you want to move all your files and run it. It took 4 seconds to process over 200 files.
A guy on the same forum claims it doesn't work with ISO files so he created another script that does. If anyone is interested in that, here it is:

@echo off
for %%a in (*.iso) do (
md “%%~na” 2>nul
move “%%a” “%%~na”
move “%%~na.jpg” “%%~na”
move “%%~na.file.jpg” “%%~na”
move “%%~na.dvdid.xml” “%%~na”
move “%%~na.mymovies.xml” “%%~na”
move “%%~na.mymovies-back.jpg” “%%~na”
move “%%~na.mymovies-front.jpg” “%%~na”
)

I would still like to know if there is anyway I can use this script code to create a custom option for doing that within x2?

Incidentally, I also found an application called File to Folder that does the same thing but also has an undo option. It costs $14.99 though. While that isn't exactly expensive, the guy who wrote the batch script above offers his own GUI version that does even more as freeware (download from the Google Code site at http://code.google.com/p/file2foldergui/).
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Re: Moving files into folders

Post by nikos »

you can do this thing using xplorer2 batch file creator (CTRL+B), something like

mkdir "f_$N", move "$N" "f_$N"

for more information see the quickstart guide
obviously the folder name cannot be the same as the file name

at first it's best to experiment with a small selection of test files
QT-Pro
Silver Member
Silver Member
Posts: 176
Joined: 2007 Jul 12, 15:55

Re: Moving files into folders

Post by QT-Pro »

nikos wrote:you can do this thing using xplorer2 batch file creator (CTRL+B), something like

mkdir "f_$N", move "$N" "f_$N"
Ctrl + B doesn't do anything. I can see it listed as Command Script under the Tools menu but that option is greyed out. Perhaps there is something I need to do in the Advanced settings to activate it?
obviously the folder name cannot be the same as the file name
Why obviously? They have to be the same ad that's exactly what the script I posted does.
Is it not possible to use that script as a custom command because I already know it works?
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Re: Moving files into folders

Post by nikos »

ctrl+B assumes you must first select the items you want to operate upon, either one or all the visible items
if you want the folder name to be the same with the mini=script I gave you, you have to add a third step that renames the f_$N into $N
QT-Pro
Silver Member
Silver Member
Posts: 176
Joined: 2007 Jul 12, 15:55

Re: Moving files into folders

Post by QT-Pro »

So what would the full script be? It's best I just copy & paste to avoid any errors.
If I understand you correctly, there is no option for making this mini-script as a custom command so I can just select it whenever needed?
Also, are the quotation marks really needed because there are none in the examples provided?
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Re: Moving files into folders

Post by nikos »

Code: Select all

mkdir "f_$N", move "$N" "f_$N", ren "f_$N" "$N"
try it first on one test file
for explanation of $N etc please see the quickstart guide
this must be executed as DOS script
QT-Pro
Silver Member
Silver Member
Posts: 176
Joined: 2007 Jul 12, 15:55

Re: Moving files into folders

Post by QT-Pro »

Executed as DOS script it works on both single and multiple files. The only problem is that it retains the extension. For example, the folder name ends in .mp4 or .mkv. Is it possible to make the folder take just the filename without its extension? Also, can the script be saved so that it can be used from either a custom command or a preconfigured script? I regret I'm having trouble understanding the quickstart guide. I'm probably too old.
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Re: Moving files into folders

Post by nikos »

in that case use this variant to skip the extensions

Code: Select all

mkdir "f_$B", move "$N" "f_$B", ren "f_$B" "$B"
QT-Pro
Silver Member
Silver Member
Posts: 176
Joined: 2007 Jul 12, 15:55

Re: Moving files into folders

Post by QT-Pro »

Thanks Nikos. That works. :)
However, I keep asking if this code can be saved and used as a custom command but for reasons unknown to me you never reply to that?
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Re: Moving files into folders

Post by nikos »

this "command" is saved in the batch file creation history, you will find it under the TEMPLATE combo box where you first typed it
QT-Pro
Silver Member
Silver Member
Posts: 176
Joined: 2007 Jul 12, 15:55

Re: Moving files into folders

Post by QT-Pro »

Thanks Nikos. Is it not possible to give the template a name so I can identify it?
As it stands it is just a line of code in the template field so not much use, especially if you have several templates.
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Re: Moving files into folders

Post by nikos »

that's all you can do with it
QT-Pro
Silver Member
Silver Member
Posts: 176
Joined: 2007 Jul 12, 15:55

Re: Moving files into folders

Post by QT-Pro »

Is it any different in v3 Ultimate?
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Re: Moving files into folders

Post by nikos »

no, it's the same :)