Batch script help

sorry my english is not that good so i will try to explain part by part.

  1. lets assume i have 50gb disk space. i will download file using rclone. may be each file 20~30gb.

  2. after download the file i process the file may be archive/screeenshot create etc using powershell script.

  3. after process done upload the file.

lets say i want to work on total 2tb files (each file may be 1~40gb). since i have limited space what i want to do is. check if folder is empty or not. if folder is empty: rclone download command will run. if folder is not empty: rclone download will not run.

If ((Get-ChildItem -Force "EMPTY FOLDER PATH") -eq $Null) {

./rclone copy "remotename:filename" "folderpath"
move command to EMPTY FOLDER PATH
}
If ((Get-ChildItem -Force "EMPTY FOLDER PATH") -eq $Null) {

./rclone copy "remotename:filename" "folderpath"
move command to EMPTY FOLDER PATH
}
If ((Get-ChildItem -Force "EMPTY FOLDER PATH") -eq $Null) {

./rclone copy "remotename:filename" "folderpath"
move command to EMPTY FOLDER PATH
}

now problem is once first rclone download command line run, it will download the file and move the file to EMPTY FOLDER PATH. after that another script will work for the download file processing.

now once rclone first download command finish. it will check if EMPTY FOLDER PATH is empty or not. if it's not empty it will keep run the command till last and end it.

any idea how how to keep retry the second download command if empty folder condition does not not match?

I'm pretty sure I don't fully understand your task here, but let me just throw in a wild guess :blush:

while ($true) {

	# Wait until empty
	while (Get-ChildItem "EMPTY FOLDER PATH" -ErrorAction Ignore) {
		Start-Sleep -Milliseconds 250
	}

	# Process one
	./rclone copy "remotename:filename" "folderpath"
	move command to EMPTY FOLDER PATH

}
1 Like

well i end up adding sleep time at the end. it's not the best way but so far i could not find a better solution. thank you for trying to help me :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.