create a folder based on filenames

November 10, 2010 at 07:53:31
Specs: Windows Server 2003
Hi,

I have many files in the below format being downloaded every day:

outbound_From-7792_To-12345_@20101110-084512
incoming_From-Unknown_To-79920_@20101110-091658
outbound_From-7796_To-0049123456789012_@20101110-105239

what I want to achieve is to take the date from the file name (20101110 in this case), create a folder 20101110 (in this case) and move all the files (*.mp3) with this date in the file name to this folder

Can you help please?


See More: create a folder based on filenames

Report •


#1
November 10, 2010 at 14:09:37
Are they the 8 chars immediately after @?


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
November 11, 2010 at 00:40:15
yes, they are

few more examples:
outbound_From-7991_To-12345667_@20101103-175157.mp3
outbound_From-7797_To-1234567890_@20100701-171811.mp3
incoming_From-123456789765432_To-8000_@20100630-173408.mp3

thanks


Report •

#3
November 11, 2010 at 02:24:58
the files are being downloaded on a daily basis, so the date (the 8 chars) is the same in every file name

thanks


Report •

Related Solutions

#4
November 11, 2010 at 05:31:36
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b *.mp3') do (
for /f "tokens=2 delims=@" %%i in ("%%a") do (
set F=%%i
set F=!F:~0,8!
if not exist !F! md !F!
)
move %%a !F!
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#5
November 11, 2010 at 05:59:57
Fantastic! It works perfectly. Thanks a lot Mechanix2Go

You are a STAR!


Report •


Ask Question