nobbi49
Goto Top

Per Batch Konfliktdateien in Dropbox suchen

Wie im Titel beschrieben suche ich eine Möglichkeit Per Batch Konfliktdateien in Dropbox zu suchen.

Ich muss in einem Ordner mit seinen Unterordnern den im Dateinamen vorkommenden Begriff "in Konflikt stehende Kopie" suchen.
Falls so eine Datei gefunden wird muss der Start einer Anwendung mit einem Hinweis gestoppt werden.

Da diese Batch auf verschiedenen Rechnern mit unterschiedlichen Installationen läuft währe es gut wenn die Dropbox als Variable definiert währe.

Ich freue mich auf Eure Lösung

Content-Key: 311305

Url: https://administrator.de/contentid/311305

Printed on: April 28, 2024 at 13:04 o'clock

Mitglied: 129813
129813 Jul 30, 2016 updated at 11:48:29 (UTC)
Goto Top
Hi,
try this
@echo off & setlocal
:: get path of dropbox folder from config file
for /f "tokens=1,* delims=: " %%a in ('findstr /ic:"path" "%APPDATA%\Dropbox\info.json"') do set "DROPBOXPATH=%%~b"  
:: find files in all folders
for /f "delims=" %%a in ('dir /b /s /a-d "%DROPBOXPATH%\*in Konflikt stehende Kopie*") do (  
   echo Found the following conflict file: '%%a'  
   set found=true
)
if "%found%" == "true" (  
     echo Cannot start application, because of conflicts!
     pause
     exit
) else (
     echo Starting application ...
     start "" "c:\Path\to\prog.exe"  
)
Regards

EDIT: did some corrections
Member: rubberman
rubberman Jul 30, 2016 at 11:11:06 (UTC)
Goto Top
@129813

A small flaw in line 15 is left. If the first parameter is enclosed into quotation marks it will be interpreted as window title. Should have been someting like ...
start "" "c:\Path\to\prog.exe"

Regards
rubberman
Member: nobbi49
nobbi49 Jul 30, 2016 updated at 11:45:39 (UTC)
Goto Top
Hallo highload
ich habe abgewandelt und bekomme die Meldung:
Die Datei "' dir /b /s /a-d "\HwDaten\*in Konflikt stehende Kopie*.*"" kann nicht gefunden werden
Starting application

Im Ordner HwDaten liegt eine Datei mit Namen AZK_016 (Norberts in Konflikt stehende Kopie 2016-05-18).xlsm

Kannst du da weiterhelfen?

@echo off & setlocal
:: get path of dropbox folder from config file

for /f "tokens=1,* delims=: " %%a in ('findstr /ic:"Path:" "D:\Dropbox\HwDaten\*in Konflikt stehende Kopie*.*"') do set "DROPBOXPATH=%%~b"  
:: find files in all folders
for /f "delims=" %%a in ('dir /b /s /a-d "%DROPBOXPATH%\HwDaten\*in Konflikt stehende Kopie*.*") do (  
   echo Found the following conflict file: '%%a'  
   set found=true
)
if "%found%" == "true" (  
     echo Cannot start application, because of conflicts!
     pause
     exit
) else (
     echo Starting application ...
   ::  start "c:\Path\to\prog.exe" 
     pause

)
Mitglied: 129813
129813 Jul 30, 2016 updated at 11:47:53 (UTC)
Goto Top
No, don't replace the paths with your own !! Only customize the path for your app. The Dropbox path is automatically determined from the config file in the Appdata folder. I wrote a comment above it face-confused, sir.