#68117 - 2002-07-13 10:08 AM
READ FILENAME - RENAME AND MOVE TO NEW FOLDER
|
Joel Ireland
Lurker
Registered: 2002-07-13
Posts: 1
|
Hey people,
I have a major problem. I know that this can be done just not how.
We have a list of HTML files that get emailed to us each week (payroll reports). These have file names like 1122002-005.html I need to be able to read the file name and move to special folders depending on the name, ie
1122 = COmpany Code (All have this) 002 = Report Type (Approx 50 Reports all 3 digits) -005 = Plant for the report, have 32 plants.
We need to be able to read these names, move them to a folder with a new name of DATE and TIME.html
Any suggestions would be great.
|
|
Top
|
|
|
|
#68120 - 2002-07-13 02:51 PM
Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
he didn't tell. just kept his topic on top. this assumes that file is to be placed in: basedir\company\reporttype\plant\date and time.html
code:
;creates folders for company, report type and plant codes if not exist ;main dir for reports: $basedir="c:\" ;place where all read from: $reportsdir = "%temp%\" $file=dir($reportsdir+"*.html") while not @error $company=left($file,4)+"\" if not exist($basedir+$company) md $basedir+$company endif $type=substr($file,5,3)+"\" if not exist($basedir+$company+$type) md $basedir+$company+$type endif $plant=right($file,3)+"\" if not exist($basedir+$company+$type+$plant) md $basedir+$company+$type+$plant endif $time=GetFileTime($reportsdir+$file) $time=right($time,4)+substr($time,6,2)+substr($time,9,2)+" "+substr($time,12,2)+"h"+substr($time,15,2)+"m"+right($time,2)+"s" copy $reportsdir+$file $basedir+$company+$type+$plant+$time+".html" del $reportsdir+$file dir() loop
[ 13 July 2002, 15:48: Message edited by: Lonkero ]
_________________________
!download KiXnet
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 756 anonymous users online.
|
|
|