Home / Microsoft / Microsoft DOS / files listed added to folder during last week
0 Members and 2 Guests are viewing this topic. « previous next »
Pages: 1 [2]  All - (Bottom) Print
Author Topic: files listed added to folder during last week  (Read 1239 times)
gpl
Apprentice



Thanked: 25
Posts: 547




« Reply #15 on: July 15, 2010, 12:31:23 AM »

Michal
Ah - spaces in names always trip me up

in this line, put quotes around the %%A
Code: [Select]
for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.*  NonExistentDirectory ' ) do call :ProcessEach "%%A"
That should cure the problem

I did not mean for you to map all of your paths to different letters, I was thinking of using 1 letter and each server path being mapped in turn to it

However if anyone else has a more elegant solution, please post here
Graham
IP logged
silberzin
Topic Starter
Rookie



Posts: 28


« Reply #16 on: July 15, 2010, 03:13:24 AM »

Hi Graham

Yes it works perfect now, all names are displayed.

The only problem is scanning network path. Local path are wotking perfect.

I just checked.
1) when I have disk p: - all works
but
2) when I use \\server_name\folder (his some path as mapped in case 1) to p:) - then script is listening files from disk where script is placed instead of network path.

I think after changing command
cd /d e:
to
dir \p \\server name\folder

it is also listing files from disk on which script was running.



I just checked by adding pause here:

Code: [Select]
>> %LogFile% echo End of LOG

pause
goto :EOF

:ProcessEach

on CMD command I can see it is listing my network files so it see link and files listed are correct form link \\server name\folder
Just entries send to  the log are not correct and come from drive where script was running.




If that can help... maybe you can have any idea :)

BR
Michal


« Last Edit: July 15, 2010, 04:09:54 AM by silberzin » IP logged
gpl
Apprentice



Thanked: 25
Posts: 547




« Reply #17 on: July 15, 2010, 04:30:52 AM »

Michal
change the line
cd /d e:
to
cd /d p:\

then do this (assuming e:\batchfile.bat is where you have saved the batchfile)
Code: [Select]
net use p: /delete

net use p: \\computer name1\share name
call e:\batchfile.bat
net use p: /delete

net use p: \\computer name2\share name
call e:\batchfile.bat
net use p: /delete

net use p: \\computer name3\share name
call e:\batchfile.bat
net use p: /delete

I have added a line that should display the servername in the log too, in this line
Code: [Select]
net use p:|find "Remote name">> %LogFile%
This should be the complete script
Code: [Select]
@echo off
CD /d p:\

REM grab todays date into variables
set MM=%Date:~3,2%
set DD=%Date:~0,2%
set YYYY=%Date:~6,4%

REM Add the date variables to the log name
REM putting the date in this order will sort the files sensibly
Set LogFile="e:\NewFiles_%YYYY%-%MM%-%DD%.Log"

REM create the vb script
>evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))

REM extract todays date less 7 days
set OldestDate=
for /f "delims=" %%A in ( ' cscript //nologo evaluate.vbs "Date -7" ' ) do set OldestDate=%%A

REM tidy
del evaluate.vbs

REM break up the date into constituent parts
REM Note - the date is parsing YYYY-MM-DD format dates,

set MM=
set DD=
set YYYY=

set MM=%OldestDate:~5,2%
set DD=%OldestDate:~8,2%
set YYYY=%OldestDate:~0,4%

REM reconstruct US format with '-' separators
set OldestDate=%MM%-%DD%-%YYYY%

REM add the new entry to the log
>> %LogFile% Echo %DATE% %TIME%
>> %LogFile% Echo Since : %OldestDate%
net use p:|find "Remote name">> %LogFile%

REM list the files that would be copied if we really were doing a copy
REM force it to believe that the target NonExistentDirectory is a directory
REM and echo the name & time for each

for /f "delims=" %%A in ( ' xcopy /l /i /d:%OldestDate% *.*  NonExistentDirectory ' ) do call :ProcessEach "%%A"

REM tidy up the log
>> %LogFile% Echo ========================================

goto :EOF

:ProcessEach

>> %LogFile% echo %~f1                       %~t1

goto :EOF
IP logged
silberzin
Topic Starter
Rookie



Posts: 28


« Reply #18 on: July 15, 2010, 05:13:20 AM »

Hi gpl

Thank you for your replay :)

Now is almost working :)

I got that error.

Code: [Select]
E:\>call e:\batchfile.bat
Access is denied.
Could Not Find P:\evaluate.vbs
The network connection could not be found.

More help is available by typing NET HELPMSG 2250.

Invalid number of parameters
There are open files and/or incomplete directory searches pending on the connect
ion to p:.

I think that is because connecting and disconnecting drive. I triet to change
Code: [Select]
Could Not Find P:\evaluate.vbs it on c:
but it keep the same.

Do you know how to fix that "tini tany problem ".

Thank you ion advance :)

last think:
Do you kno if is possible that system will not be asking:
Code: [Select]
Is it OK to continue disconnecting and force them closed? (Y/N) [N]:it may be rather annoying when we will start this task for 20 or 30 folders :)

br
Michal
IP logged
gpl
Apprentice



Thanked: 25
Posts: 547




« Reply #19 on: July 15, 2010, 06:13:58 AM »

Hi Michal
I think we can get around the problem of the vbscript, make the changes I have coloured red
REM create the vb script
>e:\evaluate.vbs echo Wscript.echo eval(WScript.Arguments(0))

REM extract todays date less 7 days
set OldestDate=
for /f "delims=" %%A in ( ' cscript //nologo e:\evaluate.vbs "Date -7" ' ) do set OldestDate=%%A


and then

REM tidy
del e:\evaluate.vbs


I do not know any more about the net use command, had to look up the syntax and it doesnt appear to have an 'always yes' parameter - there is a trick that forces a response into a command, which may work
Code: [Select]
echo Y|net use p: /delete
The source I looked up suggested that the mapping be done like this:
Code: [Select]
START /wait NET USE [driveletter:] \\ComputerName\ShareNameas it will ensure the mapping is complete before attempting to do anything with the drive

I hope this sorts out everything, if not then someone with more expertise will have to help as Im fairly lost with network things
Graham
IP logged
silberzin
Topic Starter
Rookie



Posts: 28


« Reply #20 on: July 15, 2010, 06:42:38 AM »

Hi Graham :)

I made changes,
I think it look better now :)

I add /yes to delete command, now is no problem with disconnecting diks:)

Code: [Select]
echo Y|net use p: /delete /yes


BR
Michal
« Last Edit: July 15, 2010, 06:58:47 AM by silberzin » IP logged
silberzin
Topic Starter
Rookie



Posts: 28


« Reply #21 on: July 15, 2010, 07:04:36 AM »

Hi Graham

I think script is almost perfect now :)

I have that message:

Code: [Select]

E:\>call e:\batchfile.bat
The option / is unknown.

The syntax of this command is:


NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]


More help is available by typing NET HELPMSG 3506.

Press any key to continue . . .

when I use swith "pause"

I do not know if that can generate potential problems.
Until not script seems to be working :)
« Last Edit: July 15, 2010, 07:16:16 AM by silberzin » IP logged
gpl
Apprentice



Thanked: 25
Posts: 547




« Reply #22 on: July 15, 2010, 07:20:39 AM »

I think you should remove the /yes from the net use p: /delete command

If you are remapping the P drive and calling the batch script, it should be working....
are you doing the start wait net use ..... command, this should make sure the drive is ready before you try to access it.

if you look in the log, does it record all of the servers ? or the same one multiple times ?

Graham
IP logged
silberzin
Topic Starter
Rookie



Posts: 28


« Reply #23 on: July 15, 2010, 07:29:55 AM »

Hi Graham

Unfortunatelly I tested and files listed are correct. But all come from first server, it is not looking into second file location.

2010-07-15 15:26:31,29
Since : 07-08-2010
Remote name      \\server1\folder
P:\2010070800                      2010-07-08 02:34
P:\20100712                       2010-07-12 02:39
P:\2010071                      2010-07-12 02:39

P:\24 File(s)                       
========================================
2010-07-15 15:26:32,91
Since : 07-08-2010
Remote name      \\server1\folder
P:\2010070800                      2010-07-08 02:34
P:\20100712                       2010-07-12 02:39
P:\2010071                      2010-07-12 02:39

P:\24 File(s)                       
========================================
2010-07-15 15:26:34,10
Since : 07-08-2010
Remote name      \\server1\folder
P:\2010070800                      2010-07-08 02:34
P:\20100712                       2010-07-12 02:39
P:\2010071                      2010-07-12 02:39

P:\24 File(s)                       
========================================
IP logged
gpl
Apprentice



Thanked: 25
Posts: 547




« Reply #24 on: July 15, 2010, 07:45:47 AM »

Hi
Could you post what you have that maps the servers and calls the batch - there might be something there
Thanks
Graham
IP logged
silberzin
Topic Starter
Rookie



Posts: 28


« Reply #25 on: July 15, 2010, 08:28:32 AM »


Hi Graham

Here is simple batch I got from you:
Code: [Select]
echo Y|net use p: /delete

START /wait NET USE p: \\server1\MDPRD\distributions\Inbound\70\70_Customer_flat\Archive
call e:\batchfile.bat
echo Y|net use p: /delete

echo Y|net use p: /delete
START /wait NET USE p: \\server1\MDPRD\distributions\P31\BW__RACUGRP\Archive
call e:\batchfile.bat
echo Y|net use p: /delete

START /wait NET USE p: \\server1\MDPRD\distributions\Archive
call e:\batchfile.bat
echo Y|net use p: /delete

This one I start checking folders.

BR
Michal
IP logged
gpl
Apprentice



Thanked: 25
Posts: 547




« Reply #26 on: July 15, 2010, 10:14:43 AM »

Michal
Sorry for the delay, but work got in the way

Is your server really called server1 ?
I am thinking that it is not disconnecting before the next assignment.
Put the line
Code: [Select]
@echo Y|net use p: /deletein a file called e:\disconnect_P.bat
then replace the
Code: [Select]
echo Y|net use p: /delete lines with
Code: [Select]
START /wait e:\disconnect_P.batThis may allow it to complete :
Code: [Select]
START /wait e:\disconnect_P.bat

START /wait NET USE p: \\server1\MDPRD\distributions\Inbound\70\70_Customer_flat\Archive
call e:\batchfile.bat
START /wait e:\disconnect_P.bat

START /wait NET USE p: \\server1\MDPRD\distributions\P31\BW__RACUGRP\Archive
call e:\batchfile.bat
START /wait e:\disconnect_P.bat

START /wait NET USE p: \\server1\MDPRD\distributions\Archive
call e:\batchfile.bat
START /wait e:\disconnect_P.bat
Good luck
Graham
IP logged
silberzin
Topic Starter
Rookie



Posts: 28


« Reply #27 on: July 16, 2010, 12:01:37 AM »

Hi Graham

I also think there is some disconnecting problem. I just cehcked and last (in all cases first folder stay mapped after script is finished.)
That suggest your suspiction is right.

I just changed in your script from p: disk which I use to non existing one (y:) system is promting that no disc found in one cmd, on another asking if disconnect. I answer Y but nothing happen.

When in batch file called: disconnect.bat I add
Code: [Select]
@echo Y|net use p: /delete
exit
then something happened. But still only connecting to first disk and not going to another  :'(


I have a filling that your solution is very close :)

BR
Michal
« Last Edit: July 16, 2010, 12:21:06 AM by silberzin » IP logged
silberzin
Topic Starter
Rookie



Posts: 28


« Reply #28 on: July 16, 2010, 02:44:42 AM »

Hi Graham

Just for tests I make that code:

Code: [Select]
echo Y|net use y: /delete

START /wait NET USE y: \\server1\MDPRD\distributions\Inbound\70\70_Customer_flat\Archive
call e:\batchfile.bat

echo Y|net use y: /delete

pause
echo Y|net use y: /delete


START /wait NET USE y: \\server1\MDPRD\distributions\P31\BW__RACUGRP\Archive

call e:\batchfile.bat
echo Y|net use y: /delete

here is result from cmd:



E:\>echo Y  | net use y: /delete
y: was deleted successfully.


Quote


E:\>echo Y  | net use y: /delete
y: was deleted successfully.

E:\>START /wait NET USE y: \\server1\MDPRD\distributions\Inbound\70\70_Customer_flat\Archive


E:\>call e:\batchfile.bat
The device is being accessed by an active process. <---- here net use delete  is failing

More help is available by typing NET HELPMSG 2404.

Press any key to continue . .


it has something to do with deleting network drive y: (I hanged it some time from p: to y: as I wanted to test on non used drive)

BR
Michal
« Last Edit: July 16, 2010, 03:18:46 AM by silberzin » IP logged
Pages: 1 [2]  All - (Top) Print 
Home / Microsoft / Microsoft DOS / files listed added to folder during last week « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.187 seconds with 21 queries.