Page 1 of 1 1
Topic Options
#68117 - 2002-07-13 10:08 AM READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Joel Ireland Offline
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
#68118 - 2002-07-13 02:33 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
enough refreshing. getting into this.
wait 5 mins.
_________________________
!

download KiXnet

Top
#68119 - 2002-07-13 02:47 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Lonk,
HUH? [Confused]

I would have tossed together a script but Joel didn't bother to tell us what portion of the filename was to be the folder name.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#68120 - 2002-07-13 02:51 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Lonkero Administrator Offline
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
#68121 - 2002-07-13 02:55 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
joel.
just for further posts.
the script forums description:
"Examples of scripts can be posted/discussed here."

if you have no idea what to do, you can post it to starters.
also give more info if you are not getting answers with the last post.

it gives you better chances to get what you wanted, right.

hope that script helps you.
if not what you wanted, please explain little better.

regards,
_________________________
!

download KiXnet

Top
#68122 - 2002-07-13 03:27 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Hmmm... We have a Joel and a Jooel... could get confusing...

Jooel, how 'bout I just call you Lonk?

I'm dissapointed in you work. TSK TSK TSK. You use vars in strings and spelled RIGHT as RIGTH.

Joel,
Lonk is right. This should have been posted to Starters. BTW, welcome to the board. See also the FAQ

Topic: ABC's of KiXtart board etiquette
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#68123 - 2002-07-13 03:31 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
les, sorry...
didn't check the code even once.
I almost forgot also the loop at the end.

better now?
_________________________
!

download KiXnet

Top
#68124 - 2002-07-13 03:40 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Better... only prob, return code of GetFileTime() is in the format “YYYY/MM/DD HH:MM:SS”. Need to get rid of the whacks and colons. [Big Grin]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#68125 - 2002-07-13 03:42 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah, didn't remember that windows has it's limitations [Big Grin]
fixing...
_________________________
!

download KiXnet

Top
#68126 - 2002-07-13 03:47 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
So, what is a whack and what is a hack?

I figure \\ is hack hack, and // is whack whack. What do you think?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#68127 - 2002-07-13 03:50 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
fixed,
what you think now?

I quess this comes out like the last one.
the user says after one week playing around:
"I don't actually need this, just did want to know is it possible..."

heh.
just hackin' around...
it's my life [Eek!]
_________________________
!

download KiXnet

Top
#68128 - 2002-07-13 04:10 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Haven't tested it but it looks much better. My guess is Joel is running KiX 3.47 or older and the script won't work for him. Probably bound by some corp rules on change management that won't let him upgrade whithout taking it to a committee first, so he'll abandon the project or hand it over to a VBer. [Frown]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#68129 - 2002-07-13 04:12 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
vb is also bound to versions...

man, you are answering so slowly that you haven't tested the checker yet one may say.
_________________________
!

download KiXnet

Top
#68130 - 2002-07-13 04:18 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I'm using the light weight checker F5 [Big Grin]

Remember... 26.4kbps... [Frown]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#68131 - 2002-07-13 04:24 PM Re: READ FILENAME - RENAME AND MOVE TO NEW FOLDER
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
26.4...
it means that you can get the index 1.5 times per minute...
make the looptime to something like 100seconds so you will be able to get the newpost but also do other things on the net...
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.116 seconds in which 0.076 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org