ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

Batch file to move files (less than total size) from A to B

<< < (3/4) > >>

nkormanik:
So much fun that we all should do it.

What say, gang??

(grumble, grumble, grumble....)

4wd:
So much fun that we all should do it.

What say, gang??

(grumble, grumble, grumble....)-nkormanik (April 05, 2019, 05:04 AM)
--- End quote ---

Or learn _any_ scripting language at all ...

... meanwhile ... 30 seconds later ...


--- Code: PowerShell ---<#  MoveMovies.ps1#>Add-Type -AssemblyName System.Windows.Forms Function Send-Notification {# https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/windows-scripting/x83z1d9f(v=vs.84)  param (    [string]$msg,    [int]$type  )  $wshell = New-Object -ComObject Wscript.Shell -ErrorAction Stop  $wshell.Popup($msg, 0, "MoveMovies", $type) | Out-Null}  $source = "D:\Movies"$dest = "D:\temp"$moveSize = 2000 # In gigabytes$moveSize *= 1Gb # Get list of videos in source directory$videos = (Get-ChildItem "$($source)\*" -Include *.mp4,*.mkv,*.flv,*.avi | Sort Name)for ($i = 0; $i -lt $videos.Count; $i++) {  if ($videos[$i].Length -lt $moveSize) {    Move-Item -LiteralPath "$($videos[$i].FullName)" -Destination "$($dest)"    if ($?) {      $moveSize -= $videos[$i].Length    } else {      Send-Notification "Moving file failed!" 16      break    }  } else {    Send-Notification "Maximum number of files moved into space available/allowed" 64    break  }}

nkormanik:
@highend01
@4wd
@Shades
@everyone else

Okay, here is where we now stand:  As pointed out in the url above, advice #2 is to use "another language."

That seems clear enough (especially bolded).

Who else would like to take the next step?

4wd:
Why?

PowerShell doesn't suffer from the 32bit limitation ... as shown by me setting the script above to 2TB.

The numbers must all be within the range of 32 bit signed integer numbers (-2,147,483,648 through 2,147,483,647) to handle larger numbers use PowerShell or VBScript.
--- End quote ---

highend01:
Who else would like to take the next step?
--- End quote ---
Maybe... You?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version