Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.comp.os.windows-11 > #18061 > unrolled thread
| Started by | T <T@invalid.invalid> |
|---|---|
| First post | 2025-03-29 17:03 -0700 |
| Last post | 2025-04-01 02:01 -0700 |
| Articles | 20 on this page of 80 — 16 participants |
Back to article view | Back to alt.comp.os.windows-11
what is the fastest command line copy? T <T@invalid.invalid> - 2025-03-29 17:03 -0700
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-03-29 20:43 -0400
Re: what is the fastest command line copy? T <T@invalid.invalid> - 2025-03-29 17:49 -0700
Re: what is the fastest command line copy? Andy Burns <usenet@andyburns.uk> - 2025-03-30 06:55 +0000
Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-03-31 12:08 -0700
Re: what is the fastest command line copy? Andy Burns <usenet@andyburns.uk> - 2025-03-31 20:35 +0100
Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-03-31 13:35 -0700
Re: what is the fastest command line copy? Dual Boot Windows <invalid@invalid.invalid> - 2025-03-31 02:12 +0100
Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-03-31 04:43 +0200
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-03-31 00:47 -0400
Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-03-31 11:06 +0200
Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-03-31 12:10 -0700
Re: what is the fastest command line copy? "Jonathan N. Little" <lws4art@gmail.com> - 2025-04-01 18:56 -0400
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-03-31 08:21 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-03-31 15:47 +0200
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-03-31 10:54 -0400
Re: what is the fastest command line copy? Andy Burns <usenet@andyburns.uk> - 2025-03-31 15:59 +0100
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-03-31 17:32 +0200
Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-01 07:00 +0200
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-01 09:11 +0200
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-01 03:44 -0400
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-01 09:26 -0400
Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-02 08:50 +0200
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 04:15 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 10:35 +0200
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 05:54 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 16:15 +0200
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 11:40 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 18:13 +0200
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 12:41 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 20:27 +0200
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-03 03:22 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-03 13:10 +0200
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-02 07:57 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 16:19 +0200
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-02 11:04 -0400
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 12:04 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 18:06 +0200
Re: what is the fastest command line copy? Frank Slootweg <this@ddress.is.invalid> - 2025-04-02 12:41 +0000
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 12:15 -0400
Re: what is the fastest command line copy? Frank Slootweg <this@ddress.is.invalid> - 2025-04-02 17:36 +0000
Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-04-02 10:50 -0700
Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-03 05:24 +0200
Re: what is the fastest command line copy? Democrat <Democrat@invalid.invalid> - 2025-04-03 06:00 +0000
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-03 08:39 +0200
Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-03 15:55 +0200
Re: what is the fastest command line copy? Frank Slootweg <this@ddress.is.invalid> - 2025-04-03 15:06 +0000
Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-04 13:55 +0200
Re: what is the fastest command line copy? Frank Slootweg <this@ddress.is.invalid> - 2025-04-04 12:11 +0000
Re: what is the fastest command line copy? Don_from_AZ <djatechNOSPAM@comcast.net.invalid> - 2025-04-04 10:32 -0700
Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-05 05:20 +0200
Re: what is the fastest command line copy? T <T@invalid.invalid> - 2025-04-05 00:44 -0700
Re: what is the fastest command line copy? Daniel70 <daniel47@eternal-september.org> - 2025-04-06 20:20 +1000
Re: what is the fastest command line copy? "Kerr-Mudd, John" <admin@127.0.0.1> - 2025-04-06 21:15 +0100
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-04 08:49 -0400
Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-05 05:29 +0200
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-05 08:26 -0400
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-05 00:37 -0400
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-05 08:18 -0400
Re: what is the fastest command line copy? Char Jackson <none@none.invalid> - 2025-04-03 11:00 -0500
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-02 07:53 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 16:26 +0200
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-02 11:03 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 18:04 +0200
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 12:36 -0400
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-02 13:07 -0400
Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-03 04:14 -0400
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-03 08:40 -0400
Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-04-02 10:43 -0700
Re: what is the fastest command line copy? Char Jackson <none@none.invalid> - 2025-04-02 18:59 -0500
Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-04-02 11:11 -0700
Re: what is the fastest command line copy? knuttle <keith_nuttle@yahoo.com> - 2025-03-31 10:59 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-03-31 17:26 +0200
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-03-31 13:05 -0400
Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-03-31 20:18 +0200
Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-03-31 14:43 -0400
Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-03-31 13:40 -0700
Re: what is the fastest command line copy? T <T@invalid.invalid> - 2025-03-30 23:03 -0700
Re: what is the fastest command line copy? T <T@invalid.invalid> - 2025-03-30 23:43 -0700
Re: what is the fastest command line copy? T <T@invalid.invalid> - 2025-04-01 02:01 -0700
Page 2 of 4 — ← Prev page 1 [2] 3 4 Next page →
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2025-04-01 03:44 -0400 |
| Message-ID | <vsg5ht$2ir3e$1@dont-email.me> |
| In reply to | #18139 |
On Tue, 4/1/2025 1:00 AM, Steve Hayes wrote:
> On Mon, 31 Mar 2025 10:54:31 -0400, Newyana2 <newyana@invalid.nospam>
> wrote:
>
>> On 3/31/2025 9:47 AM, R.Wieser wrote:
>>> Newyana2,
>>>
>>>> * Windows doesn't provide an option to only copy
>>>> over newer files.
>>>
>>> I don't know if Win10 still has XCopy, but it seems that it can do that :
>>>
>>> /D:m-d-y Copies files changed on or after the specified date.
>>> If no date is given, copies only those files whose
>>> source time is newer than the destination time.
>>>
>> That's not quite what I want. I usually want to just copy
>> files that don't already exist in the redundant backup. That
>> was part of the reason for the script: So that I can send 18
>> missing photos to the redundant photo folder without also
>> copying over the other 1,200.
>>
>> For me, personally, life is too short for command line. I write
>> scripts so that next time I do the same thing it will be effortless.
>> But I know that some people prefer commandline. I was just putting
>> it out there. Script is vastly more flexible and easier once the
>> script is written. But not everyone wants to learn scripting.
>
> I've hitherto uased batch files, which are a form of scripting.
>
> Is there a better tool to use for this?
At first I considered writing an answer, but a list is a good
place to start a discussion. This list isn't even complete, unfortunately.
That means, for the people who wrote this answer, they had exactly
the same problem -- not enough collective expertise to write a good
answer.
https://en.wikipedia.org/wiki/Scripting_language
At work, any time you collaborate, the first problem is
finding a common language that everyone understands. For example,
as a joke, two of us selected Fortran, even though we knew it sucked
for the job, but like good engineers, you use whatever you've got
to make stuff. We couldn't just go on a lark and take a language
course for a week, and do the project.
They don't distinguish between things that are available
as an interactive shell, or run from a file as a "script".
Some of the items in that list, are scripting languages,
others are interactive shells that also script.
cmd.exe < hereis.bat # Feeding a script of sorts, to a shell instance, referred
# to in some environments, as a "hereis" approach.
Some shells for example, fork subshells when running individual
operating system commands.
Some of the items in a shell are "built-in" functions.
There is no "dir.exe" for example, which means "dir"
must be a built-in. Some shells will actually tell
you an item is a built-in. The first item here is a built-in,
the second item is an executable at OS level.
C:\> where dir
INFO: Could not find files for the given pattern(s).
C:\> where cmd
C:\Windows\System32\cmd.exe
C:\> where copy
INFO: Could not find files for the given pattern(s).
C:\> where move
INFO: Could not find files for the given pattern(s).
C:\> where net
C:\Windows\System32\net.exe
There are enough scripting languages, that if we in the newsgroup
sat down at a table, we might have nothing in common. One
person may be a Perl expert. Another does nothing but batchscript.
I own two Perl books... and have written three lines of Perl code :-)
At my work, *all* the hardware engineers wrote Perl scripts.
I was the exception (because my design was pretty simple and
didn't need it, all I did was a processor board). I've done
complex designs (300 ICs) without crutches :-) I did it all
the "hard way".
I happen to like AWK. It can make system calls, as well as
do text processing. But that's an acquired taste, like a
lot of scripting languages. It has some severe weaknesses.
It can take two hours to figure out how to sort something.
and the only way to stat() a file, is via an add-on, which
is why I'm not allowed to post any AWK scripts that need
stat(). Because then I would have to explain arcane recipes
for how you run the damn thing.
Bot others here will be adamant batchscript people, and
I don't intend on getting into any language wars.
If you're wondering why "someone just doesn't tell you what to use",
it's because some of have been through language wars, and
we know better, about how to behave. But that also makes it
harder for you to get started.
My folks at work, were very professional about it, even though
it wasn't their specialty. My first question, they answered it.
When I came back, they said "go down to the Computer Book Store
and buy a book, after you've read it, ask us your question again".
Which was the perfect advice. The idea is, after that,
you will only be asking "interesting" questions, and not
fundamental questions. I wouldn't answer the same way here,
but that's how you do it at work.
To get really good at scripting, you need a book. While
people here could write you a script, that isn't the best
educational material. But as an example, when I wanted to
learn Bourne Shell, we got some commercial software from
some company. It had a Bourne Shell installer file. Must
have been three thousand lines of code. It had just about
every Bourne trick known to man in it :-) I hugged that puppy,
because if I needed inspiration writing a Bourne shell
script, I would open that file and scroll through it,
looking for a "programming pattern" that explains the
best way to do it. That thing was better than a book,
because it had real patterns in it. But you're not
gifted a thing like that, too often.
Paul
[toc] | [prev] | [next] | [standalone]
| From | Newyana2 <newyana@invalid.nospam> |
|---|---|
| Date | 2025-04-01 09:26 -0400 |
| Message-ID | <vsgpfb$36vg6$1@dont-email.me> |
| In reply to | #18139 |
On 4/1/2025 1:00 AM, Steve Hayes wrote:
> I've hitherto uased batch files, which are a form of scripting.
>
> Is there a better tool to use for this?
>
Big topic. I guess a lot of it depends on what you're used to.
For people who started with DOS, commandline feels natural.
And it can do some complex things. I try to avoid it because
it's relatively limited and combines coding with doing, by which
I mean, every time I want to do something I have to remember
or look up the exact syntax I'll need. So I have to write the code
every time, so to speak. The whole point of scripting for me is
so that I only have to do something once. Next time I only have
to double-click or drag-drop.
With VBScript I spend some time writing the script, but from
then on it's usually just a drag/drop operation to do repetitive
jobs. But if you know DOS and commands for various executables,
and you don't want to have to take on a whole new topic of coding,
then of course, scripting is not so conveninent.
When Microsoft invented the Windows Script Host and made
VBS/JS COM-compatible, the idea was basically to update DOS to
the GUI world. It's interpreted (script) but can do most things
that compiled software can do. As an HTA (script-powered IE
windows) it can also have a UI, buttons, etc. I've written such
tools as graphic editors, MSI installer unpackers, scanner interface,
javascript de-obfuscator, email storage database, thumbnail
viewer, base64 decoder/encoder, MP4 metadata editor, PE file
icon extractor (by parsing the resource table), and a parser for
my website server logs that replaces IP with hotsname and
location...
Lately I have a script to dig
articles out of NYTimes webpages. The NYTimes shows 3 paragraphs
and then says, "Oh, woops. We can't seem to find the rest of
the article." They've gone to great lengths to embed it in
javascript/json so that they can force javascript in order to spy
on visitors.
I also have simple scripts to do things like fix Unix
line returns in text files, write a log of sorted folder sizes for a
given location, getting subfolder through a recursive operation,
or put the text of a dropped file onto the Clipboard.
Using COM means that there are a vast number of "programlets"
that script can call into. It can automate IE. And Microsoft designs
most components to be scriptable. WMI for system info. WIA
for graphics. FileSystemObject for file/folder operations and Registry
access. Basically, VBS is easier but slower than compiled software.
Many "COM objects" were developed in concert with a Win32 API.
A COM object is essentially the same idea as an ActiveX control.
In fact, I once had a COM book written by a very cranky professor
who spent a whole page proving that "ActiveX" has no actual
meaning aside from marketing. Though in practice, ActiveX basically
means "COM objects that script can use because they have a
Dispatch or late-bound interface".
Things like
Windows Installer, Windows Image Acquisition, Windows Management,
and so on can be used in software or by script. Programmers can also
write their own COM objects. Typically there are
3 layers of access: Direct Win32 API, direct COM -- calling into the
library using datatypes -- and scripting, which must be interpreted.
For instance, the Windows Installer API allows me to unpack and
document an MSI installer file via script or in compiled software
via direct C++-style functions. There's a complete API for both
approaches. And there's a typed COM API for compiled software
that's slower than direct DLL functions but faster than the scripting
objects.
Lately I've been working on a program to download map images
and alter hue/saturation/lightness while also resizing the image.
For such a work intensive operation, GDI+ turns out to be best, but
I also tested using the WIA wrapper library via direct COM. I could
actually do this with script, but it would be even slower because I have
access the file bytes through several steps rather than as memory
addresses of bytes.
I think of it kind of like a restaurant. The cook is writing compiled
software. He can cook whatever you need. The waiter asks for
things through the order window. Both CL and WSH are waiters,
but the former has a limited menu that must be memorized, while
the latter can order nearly anything that the cook has the capacity
to make. So they serve two different purposes in many ways.
The real power is in being the cook, but that's not always feasible,
and it's sometimes not worth the work. In fact, these days, many cooks
are just glorified waiters, wrapping a number of libraries in a few codes
of .Net code. That's true not only on Windows. Things like Qt are the
workhorses for a lot of bloated multi-wrapper software that manages
to be "cross-platform" by not actually writing to any platform. The dream
of Java is now sort of possible because modern harware can handle
the massive bloat and inefficiency of such things. (Remember Longhorn?
That was going to be Microsoft's .Net-based OS. After 3 years they had
to give it up because, by their own description, no hardware existed that
could handle the excessive bloat of buildiing a whole OS on top of an
interpreted sandbox wrapper. If it had worked then we might have had
cloud and "tablet PCs" earlier.)
There's a BAT script available for downloading any desired Win10/11
ISO and writing it to USB stick or to ISO file. It's very clever, even
showing GUI menus. I haven't figured out how it does that, but it's a
nice job. In general, though, BAT, and CL generally, is limited to
one-liners. It's great if you need a DISM call and only PS can do it,
but that kind of thing is mainly intended for sysadmins doing automated
system setups. (PS was specifically designed to lure Linux sysadmins
who are used to calling applets via console. That's why you have to
call dozens of different little specialized applets rather than just
calling into it like: PS DoThis, PS DoThat, as it was with DOS.)
In this particular case, copying files, I can customize scripts to do
any kind of file operation automatically. So it's especially useful for
something like my CopyNewToFolder script. Once written I only have
to drop a folder onto the script, type in the destination, and it's done.
Later I could adjust that if needed to only copy JPGs, only copy newer
modified dates, etc.
It's not for everyone because script has a learning curve, obviously.
The COM objects also require acclimation, just as the CL objects
like robocopy or xcopy or DISM require that one know how to call
into them each time they're used.
I was offering because I can simply paste the script here. Script,
though, is more wordy than CL, and may be harder to troubleshoot
if you're not familiar with the coding. Much of the bloat is the error
trapping and convenience. The code to copy over files is compact,
but in order to make it drag-drop requires GUI message boxes and
input boxes.
In the bigger picture, MS are threatening to remove Windows Script
Host in 2027. In typical MS style they've said, "This is not our official
way of doing things anymore, which we call "deprecated", but we
understand that corporate IT people will have our heads if we break it,
so... maybe just try to get used to the idea that it won't exist forever."
MS want to rent software and put ads in it. The whole trend of
rental software requires two big transitions. One is that customers
must be acclimated to intrusion and the ruse that their software is
running "in the cloud". The other is to convince people that rental
software is better than installed software. Both claims are absurd,
especially now that most necessary software is now available as
OSS for free. So how do MS do it? By making it increasingly difficult
to actually use your own computer directly. WSH was for the handyman.
MS don't want no stinking handymen messing with their plans. So it
likely won't be long before programming options are restricted,
scripting is gone, software not from the MS store is banned "for
security reasons", and all that remains is cloudy rentals along with
PS for IT people who need to manage installing and maintaining the
actual OS. The rest will probably be something like packages. Companies
will rent "the office package" for, say, 1,500 workstations. But in the
meantime, before we're all forced to Linux, script allows people to
write much of their own software in a relatively simple way. But
don't worry, we'll probably get the "email, shopping and entertainment"
package. :)
[toc] | [prev] | [next] | [standalone]
| From | Steve Hayes <hayesstw@telkomsa.net> |
|---|---|
| Date | 2025-04-02 08:50 +0200 |
| Message-ID | <nanpujlogu6350309ttemlh3u4u3798698@4ax.com> |
| In reply to | #18155 |
On Tue, 1 Apr 2025 09:26:02 -0400, Newyana2 <newyana@invalid.nospam> wrote: >On 4/1/2025 1:00 AM, Steve Hayes wrote: > >> I've hitherto uased batch files, which are a form of scripting. >> >> Is there a better tool to use for this? >> > > Big topic. I guess a lot of it depends on what you're used to. >For people who started with DOS, commandline feels natural. >And it can do some complex things. I try to avoid it because >it's relatively limited and combines coding with doing, by which >I mean, every time I want to do something I have to remember >or look up the exact syntax I'll need. So I have to write the code >every time, so to speak. The whole point of scripting for me is >so that I only have to do something once. Next time I only have >to double-click or drag-drop. I'm not sure what you're saying here. I have four batch files: dsk2flsh.bat flsh2lap.bat lap2flsh.bat flsh2dsk.bat I only have to remember the exact syntax when I make the batch files, and after that I I have to remember is the name of the batch file. -- Steve Hayes from Tshwane, South Africa Web: http://www.khanya.org.za/stevesig.htm Blog: http://khanya.wordpress.com E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2025-04-02 04:15 -0400 |
| Message-ID | <vsiro1$1brfi$1@dont-email.me> |
| In reply to | #18175 |
On Wed, 4/2/2025 2:50 AM, Steve Hayes wrote:
> On Tue, 1 Apr 2025 09:26:02 -0400, Newyana2 <newyana@invalid.nospam>
> wrote:
>
>> On 4/1/2025 1:00 AM, Steve Hayes wrote:
>>
>>> I've hitherto uased batch files, which are a form of scripting.
>>>
>>> Is there a better tool to use for this?
>>>
>>
>> Big topic. I guess a lot of it depends on what you're used to.
>> For people who started with DOS, commandline feels natural.
>> And it can do some complex things. I try to avoid it because
>> it's relatively limited and combines coding with doing, by which
>> I mean, every time I want to do something I have to remember
>> or look up the exact syntax I'll need. So I have to write the code
>> every time, so to speak. The whole point of scripting for me is
>> so that I only have to do something once. Next time I only have
>> to double-click or drag-drop.
>
> I'm not sure what you're saying here.
>
> I have four batch files:
>
> dsk2flsh.bat
> flsh2lap.bat
> lap2flsh.bat
> flsh2dsk.bat
>
> I only have to remember the exact syntax when I make the batch files,
> and after that I I have to remember is the name of the batch file.
>
>
When those .bat files copy things, do you check
the "error number" to see if the copy
was successful ?
Scripting is "programming", and the same things I would
have to check when writing a C language program, those
are still issues when running a (so-called OS) copy program.
Here, my personal copy program returns a value of "1", if the source file
cannot be opened. This clause was written by an AI by the way.
"It doesn't have to make sense", as the AI would tell you :-)
What the AI didn't tell me, is there is a bug in one of the
library routines I should know about.
# part of paulcopy64.exe source code... Mostly written by an AI.
# I only fix them up and make them work. The comment is written by the AI.
// Open the source file in binary mode
FILE *source = fopen64(argv[1], "rb");
if (!source) {
perror("Error opening source file");
return 1;
}
Now, we test in a Command Prompt, and see if the returned integer
error code, is arriving OK or not. It is. If each error has a
different integer number, you can tell the error types apart,
with numeric checks of %errorlevel% .
D:\>paulcopy64 a b
Error opening source file: No such file or directory
D:\>echo %errorlevel%
1 # Om my! My copy did not proceed.
Making a batch file is not "just making a laundry list".
It needs conditional checks (somehow) of each
stage of the operation. And in my C program snippet, you can see
the AI is doing the same thing. The AI assumes I will be scripting
calls to "paulcopy64.exe" and scripting needs the number, to check
the program run went OK.
In scripting, you have to be careful with "volatile" items
like an %errorlevel% . They must be copied before they are lost,
by the next utility program loading its success or failure status
into that single variable in the shell.
Look at the following and note my handling mistake. The error result
from the "dir" command, has overwritten the "1" left in the %errorlevel% .
There was no error in the "dir" run and the result from it is "0".
D:\>paulcopy64 a b
Error opening source file: No such file or directory
D:\>dir
Volume in drive D
Directory of D:\
Tue, 03/18/2025 09:56 AM 252,122 paulcopy64.exe
D:\>echo %errorlevel%
0 # Oops! I lost my copy failure code.
The paulcopy64.exe was actually compiled on Ubuntu 23.04
as a cross compile, as I have not managed to get a good
mingw64 for Windows set up here. So I just cross-compiled
it, and that is why the program is 252,122 bytes, when it
should be a lot smaller for a dumb copy program.
# Asking Ubuntu to make a 64-bit version of a Windows EXE (a PE32+ EXE file).
# The FILE_OFFSET_BITS is to enable 64 bit long length fields and stuff.
# The compiler package (effectively a script) must be installed for the executable
# of the compiler, to be found. "x86_64-w64-mingw32-gcc" does not exist by default.
# This allows my program to have "gobs" of RAM, compiling it this way :-)
/usr/bin/x86_64-w64-mingw32-gcc -D_FILE_OFFSET_BITS=64 -I/usr/x86_64-w64-mingw32/include -o paulcopy64.exe paulcopy64.c
Paul
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2025-04-02 10:35 +0200 |
| Message-ID | <vsistb$1cua7$1@dont-email.me> |
| In reply to | #18177 |
Paul, > In scripting, you have to be careful with "volatile" items > like an %errorlevel% . They must be copied before they > are lost, ... > D:\>paulcopy64 a b > Error opening source file: No such file or directory > > D:\>dir > Volume in drive D > > Directory of D:\ > Tue, 03/18/2025 09:56 AM 252,122 paulcopy64.exe > > D:\>echo %errorlevel% > 0 # Oops! I lost my copy failure code. On the other hand, you should not contuinue (after the failed copy) when you are getting an error ... Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2025-04-02 05:54 -0400 |
| Message-ID | <vsj1h0$1hnn9$1@dont-email.me> |
| In reply to | #18179 |
On Wed, 4/2/2025 4:35 AM, R.Wieser wrote: > Paul, > >> In scripting, you have to be careful with "volatile" items >> like an %errorlevel% . They must be copied before they >> are lost, > ... >> D:\>paulcopy64 a b >> Error opening source file: No such file or directory >> >> D:\>dir >> Volume in drive D >> >> Directory of D:\ >> Tue, 03/18/2025 09:56 AM 252,122 paulcopy64.exe >> >> D:\>echo %errorlevel% >> 0 # Oops! I lost my copy failure code. > > On the other hand, you should not contuinue (after the failed copy) when you > are getting an error ... > > Regards, > Rudy Wieser > > That return() is on main(). Paul
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2025-04-02 16:15 +0200 |
| Message-ID | <vsjhfm$222l7$1@dont-email.me> |
| In reply to | #18181 |
Paul, > That return() is on main(). Yes, and ? Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2025-04-02 11:40 -0400 |
| Message-ID | <vsjlp1$26ef0$1@dont-email.me> |
| In reply to | #18189 |
On Wed, 4/2/2025 10:15 AM, R.Wieser wrote: > Paul, > >> That return() is on main(). > > Yes, and ? > > Regards, > Rudy Wieser > > It's the same as exit(). Execution does not continue past that point. Paul
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2025-04-02 18:13 +0200 |
| Message-ID | <vsjnoa$28jln$3@dont-email.me> |
| In reply to | #18194 |
Paul, >>> That return() is on main(). >> >> Yes, and ? > > It's the same as exit(). > > Execution does not continue past that point. Your example doesn't show a "return()" of any kind. Nor a "main()" for that matter... Bad examples are bad. :-( Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2025-04-02 12:41 -0400 |
| Message-ID | <vsjpb2$2ac7u$1@dont-email.me> |
| In reply to | #18198 |
On Wed, 4/2/2025 12:13 PM, R.Wieser wrote: > Paul, > >>>> That return() is on main(). >>> >>> Yes, and ? >> >> It's the same as exit(). >> >> Execution does not continue past that point. > > Your example doesn't show a "return()" of any kind. Nor a "main()" for that > matter... > > Bad examples are bad. :-( > > Regards, > Rudy Wieser > > Um, that was a code snippet. It is showing the CoPilot choice of an error handling pattern. If that was a subroutine or function call, the caller could do the analysis of the return value. Paul
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2025-04-02 20:27 +0200 |
| Message-ID | <vsjvjj$2gj8d$1@dont-email.me> |
| In reply to | #18201 |
Paul, [quote] > In scripting, you have to be careful with "volatile" items > like an %errorlevel% . They must be copied before they > are lost, ... > D:\>paulcopy64 a b > Error opening source file: No such file or directory > > D:\>dir > Volume in drive D > > Directory of D:\ > Tue, 03/18/2025 09:56 AM 252,122 paulcopy64.exe > > D:\>echo %errorlevel% > 0 # Oops! I lost my copy failure code. On the other hand, you should not contuinue (after the failed copy) when you are getting an error ... [/quote] > Um, that was a code snippet. I seem to be missing something.. Could you point out your "code snippet" in the above ? Yes, thats quoted from my reply to you talking about %errorlevel% losing its failure code. Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2025-04-03 03:22 -0400 |
| Message-ID | <vslcv8$32d9$1@dont-email.me> |
| In reply to | #18207 |
On Wed, 4/2/2025 2:27 PM, R.Wieser wrote:
> Paul,
>
> [quote]
>> In scripting, you have to be careful with "volatile" items
>> like an %errorlevel% . They must be copied before they
>> are lost,
> ...
>> D:\>paulcopy64 a b
>> Error opening source file: No such file or directory
>>
>> D:\>dir
>> Volume in drive D
>>
>> Directory of D:\
>> Tue, 03/18/2025 09:56 AM 252,122 paulcopy64.exe
>>
>> D:\>echo %errorlevel%
>> 0 # Oops! I lost my copy failure code.
>
> On the other hand, you should not contuinue (after the failed copy) when
> you are getting an error ...
> [/quote]
>
>> Um, that was a code snippet.
>
> I seem to be missing something.. Could you point out your "code snippet" in
> the above ?
>
> Yes, thats quoted from my reply to you talking about %errorlevel% losing its
> failure code.
>
> Regards,
> Rudy Wieser
>
So as it turns out, it's more complicated than I thought. There is ERRORLEVEL
and %errorlevel% does not actually exist. But there is a potential fallback
behavior for creating it anyway.
https://devblogs.microsoft.com/oldnewthing/20080926-00/?p=20743
"Now, it does happen to be the case that if command extensions are enabled and you say %ERRORLEVEL%,
then the command processor first looks for an environment variable called ERRORLEVEL, and if it
can’t find one, then it replaces %ERRORLEVEL% with the current value of the internal error level value.
It’s a fallback step, in the same way that your neighbor is a fallback delivery location if you aren’t home.
If you file a change-of-address form for yourself, that doesn’t affect packages sent to your neighbor. "
*******
D:\>paulcopy64 a b
Error opening source file: No such file or directory
D:\>if ERRORLEVEL 1 echo Does this print?
Does this print?
D:\>paulcopy64 a b
Error opening source file: No such file or directory
D:\>if ERRORLEVEL 0 echo Does this print?
Does this print?
So something is wrong here.
D:\>paulcopy64 a b
Error opening source file: No such file or directory
D:\>echo %errorlevel%
1
If I create an "a" file, we can try again. This is to check
that the value is actually coming from the program.
D:\>paulcopy64 a b
file_size = 0
Prepare buffer...
Starting run...
some_size read = 0
Read 0 bytes in 000.001292 seconds
some_size write = 0
Wrote 0 bytes in 000.001744 seconds
File copied successfully.
D:\>echo %errorlevel%
0
I guess the only way to prove something works then, is to
write a script and expect different behavior inside ??? I don't
have the key mentioned here, there is no HKCU Command Processor in W11.
HKCU\Software\Microsoft\Command Processor
EnableExtensions DWORD 1 # enabled
cmd /y disables command extensions for this cmd session
cmd /x enables command extensions for this cmd session
It turns out the key does already exist, but it is at this
location, making it machine wide and it is enabled.
HKLM\Software\Microsoft\Command Processor
EnableExtensions DWORD 1 # enabled
Now I can run my script
@;echo off
paulcopy64 a b
if ERRORLEVEL 1 echo The result is 1 and this is bad
With the "a" file missing, it prints
D:\>myscript.bat
Error opening source file: No such file or directory
The result is 1 and this is bad
With the "a" file present, it does not print, at the script level,
so ERRORLEVEL is something other than 1.
D:\>myscript.bat
file_size = 0
Prepare buffer...
Starting run...
some_size read = 0
Read 0 bytes in 000.001170 seconds
some_size write = 0
Wrote 0 bytes in 000.001974 seconds
File copied successfully.
If I change the script to
@;echo off
paulcopy64 a b
echo %errorlevel%
the value is falling through as Raymond explained.
D:\>myscript.bat
Error opening source file: No such file or directory
1
If I change the script to
@;echo off
paulcopy64 a b
if "%errorlevel%"=="1" echo The result is 1
and run with no "a" file
D:\>myscript.bat
Error opening source file: No such file or directory
The result is 1
Exciting. Let's see what this does.
@;echo off
set globalvar=The value is
paulcopy64 a b
set globalvar=%globalvar% %errorlevel%
REM The dot removes the leading space character
echo.%globalvar%
echo This is a test
gives an output of
D:\>myscript.bat
Error opening source file: No such file or directory
The value is 1
This is a test
And this is why I don't write batchscript. It's
about as much fun as writing in assembler.
Ref: Would not have got this far, without a web page.
It's still like pulling teeth.
https://www.tutorialspoint.com/batch_script/batch_script_quick_guide.htm
Paul
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2025-04-03 13:10 +0200 |
| Message-ID | <vslqbo$gpj3$1@dont-email.me> |
| In reply to | #18217 |
Paul, >> I seem to be missing something.. Could you point out your "code snippet" >> in >> the above ? >> >> Yes, thats quoted from my reply to you talking about %errorlevel% losing >> its >> failure code. >> >> Regards, >> Rudy Wieser >> > > So as it turns out, it's more complicated than I thought. There is > ERRORLEVEL > and %errorlevel% does not actually exist. Nice to see that you again refuse to reply when I point out something obvious. You mostly read like you are quite knowledgabe, but you lose points for that behaiviour. Also, why did you quote my whole(!) post if you where not intending to address any of it ? Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Newyana2 <newyana@invalid.nospam> |
|---|---|
| Date | 2025-04-02 07:57 -0400 |
| Message-ID | <vsj8lo$1ot1m$2@dont-email.me> |
| In reply to | #18179 |
On 4/2/2025 4:35 AM, R.Wieser wrote: > On the other hand, you should not contuinue (after the failed copy) when you > are getting an error ... > >> /usr/bin/x86_64-w64-mingw32-gcc -D_FILE_OFFSET_BITS=64 -I/usr/x86_64-w64-mingw32/include -o paulcopy64.exe paulcopy64.c Anyone who can cook up a command line like that... You don't ask questions. :)
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2025-04-02 16:19 +0200 |
| Message-ID | <vsjhfo$222l7$2@dont-email.me> |
| In reply to | #18184 |
Newyana2, > >> > /usr/bin/x86_64-w64-mingw32-gcc -D_FILE_OFFSET_BITS=64 -I/usr/x86_64-w64-mingw32/include > -o paulcopy64.exe paulcopy64.c > > Anyone who can cook up a command line like that... > You don't ask questions. :) You mean something like : %BD%\tasm32b /d?BaseName=%1 /d??Resource="%RD%" /t /kh10000 /l /m2 /i%HD%\Inc /i%HD%\Dll /i%HD%\DBG %1 Been there, done that - and put it into a batchfile. :-) Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Newyana2 <newyana@invalid.nospam> |
|---|---|
| Date | 2025-04-02 11:04 -0400 |
| Message-ID | <vsjjjq$2446b$2@dont-email.me> |
| In reply to | #18190 |
On 4/2/2025 10:19 AM, R.Wieser wrote: > %BD%\tasm32b /d?BaseName=%1 /d??Resource="%RD%" /t /kh10000 /l /m2 > /i%HD%\Inc /i%HD%\Dll /i%HD%\DBG %1 > Oh, boy. It looks like I'll have to call in some Perl nuts for backup.
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2025-04-02 12:04 -0400 |
| Message-ID | <vsjn6p$281vc$1@dont-email.me> |
| In reply to | #18193 |
On Wed, 4/2/2025 11:04 AM, Newyana2 wrote: > On 4/2/2025 10:19 AM, R.Wieser wrote: > >> %BD%\tasm32b /d?BaseName=%1 /d??Resource="%RD%" /t /kh10000 /l /m2 >> /i%HD%\Inc /i%HD%\Dll /i%HD%\DBG %1 >> > > Oh, boy. It looks like I'll have to call in some Perl nuts for backup. > With the command I cooked up, there are only so many options, and it is the process of deduction. I think only about eight possibilities, and some don't count and so on :-) I think you would find my set of lines to compile directly with the Visual Studio compiler without opening Visual Studio at all, more interesting. That one took all morning to cook up. The Linux one is more thinking than typing, the VS one is more typing than thinking. You have to install SDKs in a modern Visual Studio Community Edition, to even work with C/C++ source, and the SDKs have to be included in some of the path(s). The scary part, is tools like gcc or g++, have an infinite number of parameters, and there are people who actually understand all of it. That's well past my pay scale. Paul
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2025-04-02 18:06 +0200 |
| Message-ID | <vsjno9$28jln$2@dont-email.me> |
| In reply to | #18193 |
Newyana2 >> %BD%\tasm32b /d?BaseName=%1 /d??Resource="%RD%" /t /kh10000 /l /m2 >> /i%HD%\Inc /i%HD%\Dll /i%HD%\DBG %1 >> > > Oh, boy. It looks like I'll have to call in some Perl nuts for backup. Don't make me post the whole batchfile ! :-) Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Frank Slootweg <this@ddress.is.invalid> |
|---|---|
| Date | 2025-04-02 12:41 +0000 |
| Message-ID | <vsjiap.e54.1@ID-201911.user.individual.net> |
| In reply to | #18177 |
Paul <nospam@needed.invalid> wrote: > On Wed, 4/2/2025 2:50 AM, Steve Hayes wrote: > > On Tue, 1 Apr 2025 09:26:02 -0400, Newyana2 <newyana@invalid.nospam> > > wrote: > > > >> On 4/1/2025 1:00 AM, Steve Hayes wrote: > >> > >>> I've hitherto uased batch files, which are a form of scripting. > >>> > >>> Is there a better tool to use for this? > >> > >> Big topic. I guess a lot of it depends on what you're used to. > >> For people who started with DOS, commandline feels natural. > >> And it can do some complex things. I try to avoid it because > >> it's relatively limited and combines coding with doing, by which > >> I mean, every time I want to do something I have to remember > >> or look up the exact syntax I'll need. So I have to write the code > >> every time, so to speak. The whole point of scripting for me is > >> so that I only have to do something once. Next time I only have > >> to double-click or drag-drop. > > > > I'm not sure what you're saying here. > > > > I have four batch files: > > > > dsk2flsh.bat > > flsh2lap.bat > > lap2flsh.bat > > flsh2dsk.bat > > > > I only have to remember the exact syntax when I make the batch files, > > and after that I I have to remember is the name of the batch file. > > When those .bat files copy things, do you check > the "error number" to see if the copy > was successful ? Note that (this part of) the discussion is for .bat files which mainly contain a single 'complicated' command, so the user does not have to remember the complicated command, but just the name of hir .bat file. For *such* a .bat file, if the command fails, it will give the same error(s) as if the command was typed manually, so there's no need for checking the error number. > Scripting is "programming", and the same things I would > have to check when writing a C language program, those > are still issues when running a (so-called OS) copy program. Yes, scripting - i.e. also .bat files - is "programming", but for simple .bat files, such are under discussion here, there's no need to make things more complicated than just putting the 'complicated' command in a .bat file. [...]
[toc] | [prev] | [next] | [standalone]
| From | Paul <nospam@needed.invalid> |
|---|---|
| Date | 2025-04-02 12:15 -0400 |
| Message-ID | <vsjnrh$28nan$1@dont-email.me> |
| In reply to | #18186 |
On Wed, 4/2/2025 8:41 AM, Frank Slootweg wrote: > Paul <nospam@needed.invalid> wrote: >> On Wed, 4/2/2025 2:50 AM, Steve Hayes wrote: >>> On Tue, 1 Apr 2025 09:26:02 -0400, Newyana2 <newyana@invalid.nospam> >>> wrote: >>> >>>> On 4/1/2025 1:00 AM, Steve Hayes wrote: >>>> >>>>> I've hitherto uased batch files, which are a form of scripting. >>>>> >>>>> Is there a better tool to use for this? >>>> >>>> Big topic. I guess a lot of it depends on what you're used to. >>>> For people who started with DOS, commandline feels natural. >>>> And it can do some complex things. I try to avoid it because >>>> it's relatively limited and combines coding with doing, by which >>>> I mean, every time I want to do something I have to remember >>>> or look up the exact syntax I'll need. So I have to write the code >>>> every time, so to speak. The whole point of scripting for me is >>>> so that I only have to do something once. Next time I only have >>>> to double-click or drag-drop. >>> >>> I'm not sure what you're saying here. >>> >>> I have four batch files: >>> >>> dsk2flsh.bat >>> flsh2lap.bat >>> lap2flsh.bat >>> flsh2dsk.bat >>> >>> I only have to remember the exact syntax when I make the batch files, >>> and after that I I have to remember is the name of the batch file. >> >> When those .bat files copy things, do you check >> the "error number" to see if the copy >> was successful ? > > Note that (this part of) the discussion is for .bat files which mainly > contain a single 'complicated' command, so the user does not have to > remember the complicated command, but just the name of hir .bat file. > > For *such* a .bat file, if the command fails, it will give the same > error(s) as if the command was typed manually, so there's no need for > checking the error number. > >> Scripting is "programming", and the same things I would >> have to check when writing a C language program, those >> are still issues when running a (so-called OS) copy program. > > Yes, scripting - i.e. also .bat files - is "programming", but for > simple .bat files, such are under discussion here, there's no need to > make things more complicated than just putting the 'complicated' command > in a .bat file. > > [...] > Well, someone is expressing an interest in scripting, and I don't want them picking up any bad habits. I use a different approach than Steve, for one-liners. I have a separate notes file in the backup area, and all the one-liners are copy/pasted in there. Copy a line from that file, into a separate Notepad, edit the details as required, then paste it raw into the Terminal window, and then all the side effects are visible on the screen. It's like code inspection, doing it that way. Anything moving data around, deserves extra eyeballs. Paul
[toc] | [prev] | [next] | [standalone]
Page 2 of 4 — ← Prev page 1 [2] 3 4 Next page →
Back to top | Article view | alt.comp.os.windows-11
csiph-web