Dos Command to CD into a remote server

February 15, 2010 at 05:05:16
Specs: Windows XP
I have a batch file @ the following location E:\TEMP , A java adpater calls this file after executing certain task.I have some files at a remote server location(\\10.XXX.yyy.zz\User\X\Y).I need to code the bat file such that I change directory to(\\10.XXX.yyy.zz\User\X\Y).and then move the files present there to another folder (\\10.XXX.yyy.zz\User\X)in the same remote server.

Thanks in Advance !!


See More: Dos Command to CD into a remote server

Report •


#1
February 15, 2010 at 06:57:05
You don't need to (but you can) explicitally navigate to a directory in order to manipulate files therein ... and actually, there's an additional reason to not do it (just accept it) ... so, basically you need to move:

\\10.XXX.yyy.zz\User\X\Y\*.*

to

\\10.XXX.yyy.zz\User\X

?

I personally don't like the network notation, so my advice would be to map that machine (as any letter you want and have free), and then use the MOVE command ...

Type "move /?" for more details, it's very simple.


Report •

#2
February 15, 2010 at 12:34:42
one way:
net use K: \\10.XXX.yyy.zz\User\X
move K:\y K:

another way (after step on from above):
cd /d K:\y
move *.* ..

or another:
move \\10.XXX.yyy.zz\User\X\y \\10.XXX.yyy.zz\User\X


Report •

#3
February 15, 2010 at 21:45:20
In the net use command you used what is the k: for? is it to let the system know that it is mapped to k drive? I also need to rename them according a few conditions

Here is the code i used !!

net use "\\ULMOPKYT\S\Bo\F\U\Ba\B" /user:ID password
pushd "\\ULMOPKYT\S\Bo\F\U\Ba\B\temp\"

IF "%time:~0,1%" == " " FOR /F %%G IN ('DIR /B *.CSV') DO MOVE %%~nG.CSV ../%%~nG_0%time:~1,1%%time:~3,2%%time:~6,2%.CSV

IF "%time:~0,1%" == "1" FOR /F %%G IN ('DIR /B *.CSV') DO MOVE %%~nG.CSV ../%%~nG_%time:~0,2%%time:~3,2%%time:~6,2%.CSV

IF "%time:~0,1%" == "2" FOR /F %%G IN ('DIR /B *.CSV') DO MOVE %%~nG.CSV ../%%~nG_%time:~0,2%%time:~3,2%%time:~6,2%.CSV
popd


If i double click on the bat file it works. All the .CSV files are put in the penultimate folder
\\ULMOPKYT\S\Bo\F\U\Ba\B but if i confirure a javaadapter to use the bat file the files are not moved :( !!


The Log says
INFO : 16 Feb 2010 05:31:25,596 AC701 Process E:/JavaAdapters/X/batfile.cmd being started
INFO : 16 Feb 2010 05:31:25,612 AC703 Process E:/JavaAdapters/X/batfile.cmd started
DEBUG: 16 Feb 2010 05:31:25,612 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:26,612 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:27,612 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:28,612 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:29,612 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:30,659 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:31,659 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:32,659 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:33,659 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:34,659 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:35,659 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:36,659 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:37,659 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:38,659 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:39,659 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:40,768 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:41,909 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:42,987 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:43,987 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
DEBUG: 16 Feb 2010 05:31:44,987 AC705 Process E:/JavaAdapters/X/batfile.cmd not ended yet
INFO : 16 Feb 2010 05:31:45,987 AC706 Process E:/JavaAdapters/X/batfile.cmd did not complete in 20 seconds. It is being terminated


Report •

Related Solutions

#4
February 15, 2010 at 23:19:14
the ONLY thing i can think of, and this is lame, is that the for-loop (moving the files) is recursing or not being refreshed, from point-of-view of javaadaptors (of which i am ignorant).
It might be seeing the same directory-list each time, even tho files have been moved out of it by the batch. If you can make your java echo the files you might gain a clue. It looks like a communications-gap between java and batchscript, but i am very prob'ly wrong.
other poss. but probly not effective either:
(javaadapt:)
start /w e:temp\xx.bat
instead of just e:\temp\xx.bat

as for K:, that is just a shortcut to map drive K to the server and path: \\10.XXX.yyy.zz\User\X
it is not crucial to the operation.

you'll get more proffessional help tomorrow...


Report •

#5
February 16, 2010 at 00:41:08
Thanks for the reply :)
I dont think the for loop is a problem, coz The Java adapter could process the bat file with the following code in it


CD /D E:\DA\TA\TEMP

IF "%time:~0,1%" == " " FOR /F %%G IN ('DIR /B *.CSV') DO MOVE %%~nG.CSV ../%%~nG_0%time:~1,1%%time:~3,2%%time:~6,2%.CSV
IF "%time:~0,1%" == "1" FOR /F %%G IN ('DIR /B *.CSV') DO MOVE %%~nG.CSV ../%%~nG_%time:~0,2%%time:~3,2%%time:~6,2%.CSV
IF "%time:~0,1%" == "2" FOR /F %%G IN ('DIR /B *.CSV') DO MOVE %%~nG.CSV ../%%~nG_%time:~0,2%%time:~3,2%%time:~6,2%.CSV


and all files are moved to the location
CD /D E:\DA\TA\
The For loop works fine.The only problem I see is to current directory to the directory on server n then access the files


Report •

#6
February 16, 2010 at 11:43:48
> move *.* ..

Noooooooooooooooooo ...

DONT
USE
THIS
ONE-LINER


Report •

Ask Question