How to find folder, if path is unknown.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
vairiks123
Posts: 6
Joined: 24 Jul 2016 08:49

How to find folder, if path is unknown.

#1 Post by vairiks123 » 11 Aug 2016 02:55

So, here is piece of my code for script that I am making:

Code: Select all

:January
cls
cd \\sharename\folder
if not exist "\\sharename\folder\01_2016" mkdir "\\sharename\folder\01_2016"
ECHO Folder is Created!
ECHO Moving Files...
MOVE "\\sharename\folder\??_01" "\\sharename\folder\01_2016"
ECHO Creating Backup!
for /d %%X in (01_2016) do "C:\Program Files\7-Zip\7z.exe" a "%%X.7z" "%%X\"
ECHO Please wait few seconds...
ping 1.0.0.0 -n 1 -w 3000 >NUL
ECHO Backup is Created!
ECHO Sending Backup to servername\sharename\folder
MOVE "\\sharename\folder\01_2016.7z" "\\servername\sharename\folder"
cls
pause
GOTO MENU


Now, my problem is, that my coworker will use this same script from his thumb drive, which would be ok, but, path that I use for cd, move etc. commands are used for local network. My coworker want's to use this script on other Local networks, so, that means that script will NOT be able to find "\folder\something.txt" becouse sharename can have different name.

So, in case my coworker wants to move files from local computer to server, this will happen:

Code: Select all

MOVE "\\?????????????\folder\01_2016.7z" "\\servername\sharename\folder"


Which will turn out to be error.

I found out, how to find path to directory in C drive, but this won't work on Local Network:

Code: Select all

For /f "delims=" %%A in ('dir c:\file.txt /a /s /b') Do echo %%A


For /f "delims=" %%A in ('dir \\folder\file.txt /a /s /b') Do echo %%A

Here is the question -
How to Search local network for \\folder\file.txt without using sharename?
If it's possible, how do I add %%A as a target path to local network folder?

That's all, and sorry for bad english ofcourse :)


Post Reply