Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

using PDIR unusually

Aug
258
4
Hi,

today I had a new problem which I solved with PDIR.

We have some production-line machines ("ager") which send many hundreds (measuring?) data per day to a windows ftp-server.
Under the ftp-root there is a directory for each machine and subdirectories for each day + month + year.
These are pre-created until 2025:

Code:
C:\Inetpub\ftproot\AGER_2_BK\
+--2012
|  +--01
|  |  +--01
|  |  +--02
|  |  +--03
|  |  +--04
|  |  +--05
|  |  +--06
|  |  +--07
|  |  +--08
|  |  +--09
|  |  +--10
|  |  +--11
|  |  +--12
|  |  +--13
|  |  +--14
|  |  +--15
|  |  +--16
|  |  +--17
|  |  +--18
|  |  +--19
|  |  +--20
|  |  +--21
|  |  +--22
|  |  +--23
|  |  +--24
|  |  +--25
|  |  +--26
|  |  +--27
|  |  +--28
|  |  +--29
|  |  +--30
|  |  \--31
|  +--02
|  |  +--01
|  |  +--02
|  |  +--03
|  |  +--04
|  |  +--05  and so on

The machines shall transfer the files directly into today's subdir, e.g. "AGER_2_BK\2012\02\17", which normally works fine.
Sadly no one noticed that obviously these dumb machines sometimes have no date+time information.
What did they do? They put the files directly unter its machine-directory, e.g. "AGER_2_BK\" !
Now I have some thousand files in one plain directory which have to be sorted into the correct yyyy\mm\dd subdir manually.

So how can I sort them into the correct subdir? Using "move" with date-range? Or with parts of %@filedate[] ?
That all would require loops and coding stuff...

I came to the idea of creating a temp-script with PDIR by using the ability to combine strings and pdir-fields:

Code:
@echo off
setlocal
 
set agerdir=ager_2_bk
echo give ager-dir:
eset agerdir
 
pdir /("move /q %agerdir\"fnq" %agerdir\"dy"\"dm"\"dd"\") %agerdir\*.agr > move-agr_tmp.btm
 
:end
endlocal
quit

This is an excerpt of "move-agr_tmp.btm":
Code:
move /q ager_2_bk\"0009317550.0403K91V.                .2.107.10.agr"  ager_2_bk\2010\10\07\
move /q ager_2_bk\"0009336022.0403K91P.                .2.107.04.agr"  ager_2_bk\2010\10\07\
move /q ager_2_bk\"0009336149.0403K91R.                .2.107.06.agr"  ager_2_bk\2010\10\07\
move /q ager_2_bk\"0009336154.0403K91T.                .2.107.08.agr"  ager_2_bk\2010\10\07\
move /q ager_2_bk\"0009336283.0403K91Q.                .2.107.05.agr"  ager_2_bk\2010\10\07\
move /q ager_2_bk\"0009336287.0403K91W.                .2.107.11.agr"  ager_2_bk\2010\10\07\
move /q ager_2_bk\"0009336694.0403K91S.                .2.107.07.agr"  ager_2_bk\2010\10\07\
move /q ager_2_bk\"0009337124.0403K91O.                .2.107.03.agr"  ager_2_bk\2010\10\07\
move /q ager_2_bk\"0009337266.0403K91N.                .2.107.02.agr"  ager_2_bk\2010\10\07\
move /q ager_2_bk\"0009338047.0403K91U.                .2.107.09.agr"  ager_2_bk\2010\10\07\
move /q ager_2_bk\"0010901545.1153M29G.                .2.013.03.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010901620.1153M29J.                .2.013.06.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010901637.1153M29M.                .2.013.09.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010901718.1153M29N.                .2.013.10.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010901975.1153M29P.                .2.013.12.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010936389.1141N47C.                .2.011.10.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010936493.1141N46W.                .2.011.06.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010936535.1141N46R.                .2.011.01.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010936595.1141N47E.                .2.011.12.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010936609.1141N47B.                .2.011.09.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010936721.1141N46S.                .2.011.02.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010936780.1141N46V.                .2.011.05.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010936798.1141N46T.                .2.011.03.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010936901.1141N46X.                .2.011.07.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010936916.1141N46U.                .2.011.04.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010937360.1141N47D.                .2.011.11.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010937732.1141N47A.                .2.011.08.agr"  ager_2_bk\2011\04\05\
move /q ager_2_bk\"0010944922.1153M29O.                .2.013.11.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010945102.1153M29L.                .2.013.08.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010945188.1153M29K.                .2.013.07.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010945392.1153M29H.                .2.013.04.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010945418.1153M29I.                .2.013.05.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010953082.1153M29E.                .2.013.01.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"0010953252.1153M29F.                .2.013.02.agr"  ager_2_bk\2011\04\14\
move /q ager_2_bk\"4070197744.0223K52C.                .2.115.11.agr"  ager_2_bk\2010\06\03\
move /q ager_2_bk\"4070208449.0313K63I.                .2.114.04.agr"  ager_2_bk\2010\08\04\

Calling "move-agr_tmp.btm" worked fine and went pretty fast.
Any better idea?
 
Back
Top
[FOX] Ultimate Translator
Translate