Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Need for help :)

Aug
1
0
Hello,

Even though I have been using the great products of JP Software for a long time (4DOS, 4NT and now TCMD/TCC), I have to confess that I have been using them in a quite basic way. Even though I have written a few .btm files over the years, they have been very simple and meant to solve simple, uncomplicated tasks.

However, I am now in need of a more complex batch file, and I do not know how to organize this project; which functions to use to achieve what I want, and if this at all is possible to do (although I would be surprised if not). :-)

This is what I want the batch file to do:
1. Check which external drives are connected to the computer
2. Check free disk space on each external drive
3. Move a number of files from a directory on an internal drive to the first external drive that has room for them

Any help would be highly appreciated.

Best regards,
Tore Johnny (TJ) Bratveit
 
I am only just starting to use the latest version of TCC, having been accustomed to a Win XP-compatible version of 4NT for a very long time. So I'm not up-to-date about all of the latest functions, but a quick look through the help-file suggests to me that you might want to look up the following functions:

@DriveType
@DrivetypeEx

Also, a search for "drives" will probably help. Click the "Title" tab in the results window to sort the list alphabetically. The variable functions will then appear at the top.
 
I just type here two aliases, grabbed here and there inside this forum. They are meant to detect the free space on the available disks.
I think that the variables _ready, @DISKUSED, @DISKTOTAL, @DISKFREE can turn useful for your project.

(1) This alias is written with backstics, to prevent the immediate expansion of variables with %
alias df=`echo Disk Used/Total Workdir & for %d in ( %_ready ) echo %d %@DISKUSED[%d,g]/%@DISKTOTAL[%d,g] Gbytes %@CWD[%d]`

(2) This one uses double %% to avoid the expansion:

alias spaziodisco=for %%d in ( %%_ready ) echo %%d %%@format[8,%%@comma[%%@disktotal[%%d,M]]] %%@format[8,%%@comma[%%@diskused[%%d,M]]] %%@format[8,%%@comma[%%@diskfree[%%d,M]]] %%@eval[ 100-(%%@diskfree[%%d] / %%@disktotal[%%d]*100=0)]%%%%

Note "spazio disco" means "disk space" in Italian. But the original alias is form someone else with another name.
 
%_ready lists the drives which are available; @removable[] shows whether or not the tested drive is ready; @diskfree[] how much space is available on the tested drive. @filesize[] reports the total size of all files specified. This gives you the tools to create a rudimentary batch program to do the job. But there is a potential issue if the allocation unit (cluster size) of the target (removable) drive is larger than the source (internal) drive - the allocated space on the target drive may be sufficiently larger than on the source drive to exceed its free space. The simplest way to avoid it is to use any of the internal commands used for archiving: GZIP, TAR, ZIP. Even a TAR archive, which uses no compression, avoids the issue, because its allocation unit is 512 bytes, not larger than any hard disk drive. However, archives must also store the information which would be stored in the disk directory about each file within the archive. Which requires more space on the target drive - its native file system directory entries or archive directory entries - depends on the file system and archiving format. If the backup drive uses NTFS, and your OS supports file compression (WinXP Pro, or any later version of Windows), you can use NTFS' own compression; this does not necessarily avoid the cluster size issue, because non-empty files cannot be compressed to less than one cluster. Most batch files do not exceed a cluster, and are thus incompressible.

HTH, Steve
 
Back
Top