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

<< < (2/4) > >>

nkormanik:
@highend01
@4wd
@Shades

Agree that native Explorer begs for enhancements.  I've tried to do that with whatever third-party upgrades I could find.

Another alternative file manager, though, is definitely something to consider.

Regarding the present challenge, one double-click seems super appealing, if highend01 could pull off the wizardry.  Like, wow!

I'll try 4wd's offering.  Looks promising.

nkormanik:
@highend01
@4wd
@Shades

4wd, works as advertised.  Very slick.  Thank you!

Let's see if highend01 can code it into a batch file, for single double-click.

Still wondering if that's possible.

highend01:
You are kidding me, right?

That's the exact same thing, only in green...


--- ---@SETLOCAL EnableDelayedExpansion
@ECHO OFF

REM 1 MB = 1048576 bytes
REM 157286400 = 150 MB
SET Max=157286400
SET Src=R:\tst_src
SET Dst=R:\tst_dst

IF EXIST "%Src%" (
    IF EXIST "%Dst%" (
        SET /a Size = 0
        FOR %%I IN ("%Src%\*") DO (
            SET /a Size += %%~zI
            IF !Size! GTR %Max% GOTO :EOF
            MOVE /Y "%%I" "%Dst%" >NUL 2>NUL
        )
    )
)

nkormanik:
Well, @highend01, that's some amazing stuff.  Thank you!

Basically works as asked for, as a one double-click trick.  Files up to a certain total-size limit get moved to the new location.

One issue did come up, though.  Via this approach there appears to be an inherent upper limit.  At 2 GB.  No matter how high the user inputs their own upper limit, Windows stops short.

Hmmm.  Any idea why?

I suppose user (me) can come back for seconds, and thirds.  I.e., run the batch file multiple times.

highend01:
Google stopped working (again)?

https://stackoverflow.com/questions/32930168/invalid-number-numbers-are-limited-to-32-bits-of-precision

Includes ways how to circumvent this restriction. Have fun learning a minimal amount of batch scripting!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version