Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

create folder which is named by date of file

78 views
Skip to first unread message

Mark Ise

unread,
Mar 26, 2012, 12:38:07 PM3/26/12
to
Hello,

I would like to create folders whose names are parts of the create dates
from files in one specific folder.
After that the files should be moved to the corresponding folder.

For example:

There are several files:

X:\scan_temp\namexy.pdf create date 3.4.2012
X:\scan_temp\nameyz.pdf create date 1.2.2011
X:\scan_temp\name123.pdf create date 5.7.2010
...

If the folders not exist the batch program should create the folders:
x:\scan\2012-04-03
x:\scan\2011-02-01
x:\scan\2010-07-05
...


I think it should be possible but I don't know how to begin and how to
test if the folders exist.


--
Mark

John Gray

unread,
Mar 26, 2012, 1:47:13 PM3/26/12
to
Before you get any further, I would point out that the create date of a file, and even more so of a folder, is Very Unreliable. The only date you can really rely on is the Modified=Changed Date of a file...

Mark Ise

unread,
Mar 26, 2012, 2:53:27 PM3/26/12
to
John Gray schrieb am 26.03.2012 19:47:
> On Monday, March 26, 2012 5:38:07 PM UTC+1, Mark Ise wrote:

>> I would like to create folders whose names are parts of the create dates
>> from files in one specific folder.
>> After that the files should be moved to the corresponding folder.


> Before you get any further, I would point out that the create date of a file, and even more so of a folder, is Very Unreliable. The only date you can really rely on is the Modified=Changed Date of a file...

Why is it unreliable?

Maybe it is unreliable generally.
In my case I think it should work. My scanner software puts all the
files into a specific folder. Sometimes immediately and sometimes after
a few days I rename the files and then the files should be sorted in
folders with create date.
There should be no other copy action meanwhile.

--
Mark
Message has been deleted

foxidrive

unread,
Mar 26, 2012, 5:21:11 PM3/26/12
to
On 27/03/2012 07:51, Guy wrote:
> If you are willing to change your Regional Date setting to yyyy-MM-dd
>
>
> CD /D X:\SCAN_TEMP
> FOR %%I IN (*) DO (
> FOR /F "tokens=1" %%D IN ('DIR /A-D /TC %%I^|FINDSTR "%%I"') DO (
> IF NOT EXIST X:\SCAN\%%D MD X:\SCAN\%%D
> MOVE %%I X:\SCAN\%%D
> )
> )
>
>
> Else you will need to parse/rearrange the create date.

In case there are files or folders with long filename elements then you'll need the modifications below.


@echo off
CD /D X:\SCAN_TEMP
FOR %%I IN (*) DO (
FOR /F "tokens=1" %%D IN ('DIR /A-D /TC "%%I"^|FINDSTR "%%I"') DO (
IF NOT EXIST "X:\SCAN\%%D\" MD "X:\SCAN\%%D"
MOVE "%%I" "X:\SCAN\%%D"
)
)





--
Mic

John Gray

unread,
Mar 27, 2012, 1:09:47 AM3/27/12
to
Why is it unreliable? Because it is inconsistently updated. Although olde, this technical note still applies: http://www.xxcopy.com/xxcopy15.htm

Dr J R Stockton

unread,
Mar 28, 2012, 1:11:16 PM3/28/12
to
In alt.msdos.batch.nt message <jkq61g$7v5$1...@dont-email.me>, Mon, 26 Mar
2012 18:38:07, Mark Ise <mark...@arcor.de> posted:

>I would like to create folders whose names are parts of the create dates
>from files in one specific folder.

Be aware that the file/folder date/times reported by Windows may change
if the machine considers the time offset from GMT to have changed - for
example, by travel or by the change to/from Summer Time.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Website <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
0 new messages