Creating a folder whit name of the file

Microsoft Windows 7 pro - enterprise w/m...
August 16, 2010 at 07:03:45
Specs: Windows 7, 2048
Hi,

I'm tring to do something like this:

I have multiple files (*.jpg) with similar names, like this ex: 060658_411_100517_03.jpg;
061379_0600_02_09_05_07;

What i pretend it's create a folder with the first 2 part's of the files name, like this:

xxxxxx_xxx or xxxxxx_xxxx

After that moves the file that gave the folder name to that folder!!

Can anyone give a litle help?

Best Regard's


See More: Creating a folder whit name of the file

Report •

#1
August 17, 2010 at 03:41:17
After search for similar cases, i found this code!!

@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims=_" %%a in ('dir/b/a-d *.jpg') do (
set F=%%~Na
set F=!F:~0,10!
if not exist "!F!" md "!F!"
move "%%a" "!F!")

It creates the folder with the first 10 characters and then move the file to it...

It works!


Report •
Related Solutions


Ask Question