jquery – Updating sharepoint list items with batch pnp, in bad request

I’ve used this guide to create my batch and update the items.

var list = pnp.sp.web.lists.getByTitle("Categories");
list.getListItemEntityTypeFullName().then(entityTypeFullName => {
    var batch = pnp.sp.createBatch();
    $(`.${css.SortContent} table tbody tr`).each(function (ind, con) {
        var id: any = $(con).attr("data-catid");
        var newOrder: any = parseInt($(con).find(`.cat_select :selected`).text());
        list.items.getById(id).inBatch(batch).update({
            Order: newOrder
        }, "*", entityTypeFullName).then(() => {
            console.log("test");
        });
    });
    batch.execute().then(r => {
        console.log(r);
    }).catch((e) => {
        console.log(e);
    });
});

Information: There are 3 tr‘s inside the body. In my test, they give these results:

id = 1; newOrder = 2
id = 2; newOrder = 1
id = 3; newOrder = 3

When I run the code, this is the following result:

console.log(test) never runs
console.log(r) logs undefined
console.log(e) never runs

If I log batch just before it’s executed, I’m able to see 3 items inside. So I know the items are added to the batch.

But the items are never updated, and all I get is.

Error: Error making HttpClient request in queryable: (400) Bad Request

Image of the batch log:

enter image description here

Can anyone tell me what I’m doing wrong?

Update: It looks like "X-HTTP-Method": "MERGE" is missing.

enter image description here

Batch download a bunch of files, limiting the download size to 100 KB [migrated]

I have lots of URLs of large files(>1 GB) and plan to open them by Bulk URL Opener. It automatically starts downloading once URL is opened, I need it to pause or stop once 100 KB have been downloaded.

Is there anyway I can automate it, I can pause once I see 100 KB downloaded in downloads bar of any browser, but manually doing it for 1000s of URL is hectic.

Note that many solution I tried involves downloading a complete file and then returning only first 100 KB. This is not what I want.

Confused about goto label (batch file) Windows

Your batch file executes from the top down.

In the second example, even if foo2 or foo1 is set, it’s always going to go to :another_menu. The only way the batch file will move past those two statements is if both foo1 and foo2 are set.

You are essentially creating a logical OR situation.

If foo1 OR foo2 is not set go to another_menu

ELSE

If foo1 OR foo2 is set go to foobar_menu

ELSE

Do nothing

Whereas the first example,

If foo1 OR foo2 is set go to foobar_menu

ELSE

If foo1 OR foo2 is not set go to another_menu

ELSE

Do nothing

What you need is specifically a logical AND. Batch file IF statements do not support either AND or OR. So, we nest them or chain them like so:

if not "%foo1%"=="bar1" if not “%foo2%” goto :another_menu

This says,
If foo1 is not set then if foo2 is not set goto :another_menu

Or, more easily,
If foo1 AND foo2 are not set goto another_menu

Can this batch file damage/prevent Windows 10 from booting?

Is there any chance, anything in the following batch could possibly delete/damage/corrupt any useful Windows 10 files (drivers, registry or other useful components), to the point of preventing them from even starting and causing a bootloop?

Caution: Don’t run this code as it might damage your system

takeown /f "H:PVR" /r
icacls "H:PVR" /reset /T
FOR /R "H:PVR" %%i IN (*.ts *.tsv) DO MOVE "%%i" "H:PVR"
CD /D "H:PVR"
ren *.tsv *.ts
for /f "delims=" %%d in ('dir /ad /b') do @rd /q /s "%%d"
setlocal EnableDelayedExpansion
for %%a in (*.ts *.tsv) do (
   set name=%%~Na
   set num=00!random!
   set newName=!!name:~-17!
   ren "%%a" "!newName!%%~Xa"
)

It’s a batch file I put together combining several commands found here and other places, in order to process .ts recodings from my DVBT-T2 receiver, stored in a flash drive.
The idea is to:

a). Take permission for the “H:PVR” and all its contents (the PVR folder in my flash drive).

b). Take the .tsv recordings out of the subfolders, then delete those subfolders.

c). Rename .tsv extension to .ts

d). Remove the first 17 characters from the filenames (cause I don’t like the prefix format of my receiver).

Please note I ran the batch file (as admin) both from the flash drive AND my C: drive, where Windows are installed. Then a CMD window opened and I saw filenames which are not in my flash drive being processed which was fishy….
My code skills are bad and I am trying to learn by adapting, but I never throught I could create a Frankenstein code that could do that. Please go ahead and tell me I’ve done something so foolish, I will be actually VERY HAPPY to hear so, because it’s the second time within 10 days that I am getting a nasty bootloop (no instant BSOD btw, but after running the bat file, ever since the next reboot, Windows won’t start and display “Critical Service Failed”), and I’ve been trying hard to troubleshoot it, to no avail. Bonus points for letting me know what’s the mistake and how to correct it, but just letting me know whether it could be responsible is also absolutely fine!

Please tell me it’s not a coincidence. Thank you.

How to rename multiple uniquely name directories on a mapped drive with unique names in a batch file

I have a mapped drive with multiple uniquely named folders containing files. I want to rename each folder with a batch file.

V:MediaElton JohnSingles>dir
 Volume in drive V is DATA3
 Volume Serial Number is 50CF-6A6E

 Directory of V:MediaElton JohnSingles

2021-04-17  05:16 AM    <DIR>          .
2020-09-22  10:14 AM    <DIR>          ..
2021-04-09  06:47 AM    <DIR>          1969-01 Lady Samantha - All Across The Heavens (7'', Philips BF 1739)
2021-04-09  07:36 AM    <DIR>          1970-07 Border Song - Bad Side Of The Moon (7'', UNI 55246)
2021-04-09  06:50 AM    <DIR>          1970-08 Rock And Roll Madonna - Grey Seal (7'', Supreme S. 147)
.
.
.

I want to rename each uniquely named directory with a unique name – examples:

1969-01 Lady Samantha - All Across The Heavens (7'', Philips BF 1739)"
1970-07 Border Song - Bad Side Of The Moon (7'', UNI 55246)
1970-08 Rock And Roll Madonna - Grey Seal (7'', Supreme S. 147)

I created a batch file – the pauses are so I can abort the batch file if there are problems:

ren "1969 - Lady Samantha. All Across The Heavens (7'', Philips BF1739)" "1969-01 Lady Samantha - All Across The Heavens (7'', Philips BF 1739)"
PAUSE
ren "1971 - Border Song. Bad Side Of The Moon (7'', UNI 55246)" "1970-07 Border Song - Bad Side Of The Moon (7'', UNI 55246)"
PAUSE
ren "1970 - Rock'n'Roll Madonna. Grey Seal (7'', Supreme DJS 222)" "1970-08 Rock And Roll Madonna - Grey Seal (7'', Supreme S. 147)"

I ran it and got:

C:WINDOWSsystem32>cd V:MediaElton JohnSingles

C:WINDOWSsystem32>V:

V:MediaElton JohnSingles>C:UsersMarcDesktopEJSingles.bat

V:MediaElton JohnSingles>ren "1969 - Lady Samantha. All Across The Heavens (7'', Philips BF1739)" "1969-01 Lady Samantha - All Across The Heavens (7'', Philips BF 1739)"
The system cannot find the file specified.

V:MediaElton JohnSingles>PAUSE
Press any key to continue . . .

V:MediaElton JohnSingles>ren "1971 - Border Song. Bad Side Of The Moon (7'', UNI 55246)" "1970-07 Border Song - Bad Side Of The Moon (7'', UNI 55246)"
The system cannot find the file specified.

V:MediaElton JohnSingles>PAUSE
Press any key to continue . . .

V:MediaElton JohnSingles>ren "1970 - Rock'n'Roll Madonna. Grey Seal (7'', Supreme DJS 222)" "1970-08 Rock And Roll Madonna - Grey Seal (7'', Supreme S. 147)"
The system cannot find the file specified.

V:MediaElton JohnSingles>

I stripped out the quotes and got:

V:MediaElton JohnSingles>C:UsersMarcDesktopEJSingles.bat

V:MediaElton JohnSingles>ren 1969 - Lady Samantha. All Across The Heavens (7'', Philips BF1739) 1969-01 Lady Samantha - All Across The Heavens (7'', Philips BF 1739)
The syntax of the command is incorrect.

V:MediaElton JohnSingles>PAUSE
Press any key to continue . . .

V:MediaElton JohnSingles>ren 1971 - Border Song. Bad Side Of The Moon (7'', UNI 55246) 1970-07 Border Song - Bad Side Of The Moon (7'', UNI 55246)
The syntax of the command is incorrect.

V:MediaElton JohnSingles>PAUSE
Press any key to continue . . .

V:MediaElton JohnSingles>ren 1970 - Rock'n'Roll Madonna. Grey Seal (7'', Supreme DJS 222) 1970-08 Rock And Roll Madonna - Grey Seal (7'', Supreme S. 147)
The syntax of the command is incorrect.

V:MediaElton JohnSingles>

I added the complete path to the batch file:

ren "V:MediaElton JohnSingles1969 - Lady Samantha. All Across The Heavens (7'', Philips BF1739)" "V:MediaElton JohnSingles1969-01 Lady Samantha - All Across The Heavens (7'', Philips BF 1739)"
PAUSE
ren "V:MediaElton JohnSingles1970 - Take Me To The Pilot. Your Song (7'', UNI 55265)" "V:MediaElton JohnSingles1970-10 Take Me To The Pilot - Your Song (7'', UNI 55265)"
PAUSE
ren "V:MediaElton JohnSingles1970 - Rock'n'Roll Madonna. Grey Seal (7'', Supreme DJS 222)" "V:MediaElton JohnSingles1970-08 Rock And Roll Madonna - Grey Seal (7'', Supreme S. 147)"

I got:

V:MediaElton JohnSingles>C:UsersMarcDesktopEJSingles.bat

V:MediaElton JohnSingles>ren "V:MediaElton JohnSingles1969 - Lady Samantha. All Across The Heavens (7'', Philips BF1739)" "V:MediaElton JohnSingles1969-01 Lady Samantha - All Across The Heavens (7'', Philips BF 1739)"
The system cannot find the file specified.

V:MediaElton JohnSingles>PAUSE
Press any key to continue . . .

V:MediaElton JohnSingles>ren "V:MediaElton JohnSingles1970 - Take Me To The Pilot. Your Song (7'', UNI 55265)" "V:MediaElton JohnSingles1970-10 Take Me To The Pilot - Your Song (7'', UNI 55265)"
The system cannot find the file specified.

V:MediaElton JohnSingles>PAUSE
Press any key to continue . . .

V:MediaElton JohnSingles>ren "V:MediaElton JohnSingles1970 - Rock'n'Roll Madonna. Grey Seal (7'', Supreme DJS 222)" "V:MediaElton JohnSingles1970-08 Rock And Roll Madonna - Grey Seal (7'', Supreme S. 147)"
The system cannot find the file specified.

V:MediaElton JohnSingles>

Lastly I tried using the complete path without quotes:

V:MediaElton JohnSingles>C:UsersMarcDesktopEJSingles.bat

V:MediaElton JohnSingles>ren V:MediaElton JohnSingles1969 - Lady Samantha. All Across The Heavens (7'', Philips BF1739) V:MediaElton JohnSingles1969-01 Lady Samantha - All Across The Heavens (7'', Philips BF 1739)
The syntax of the command is incorrect.

V:MediaElton JohnSingles>PAUSE
Press any key to continue . . .

V:MediaElton JohnSingles>ren V:MediaElton JohnSingles1970 - Take Me To The Pilot. Your Song (7'', UNI 55265) V:MediaElton JohnSingles1970-10 Take Me To The Pilot - Your Song (7'', UNI 55265)
The syntax of the command is incorrect.

V:MediaElton JohnSingles>PAUSE
Press any key to continue . . .

V:MediaElton JohnSingles>ren V:MediaElton JohnSingles1970 - Rock'n'Roll Madonna. Grey Seal (7'', Supreme DJS 222) V:MediaElton JohnSingles1970-08 Rock And Roll Madonna - Grey Seal (7'', Supreme S. 147)
The syntax of the command is incorrect.

V:MediaElton JohnSingles>

I’m using Notepad to write the batch file – Word Wrap IS NOT on.

I’m probably forgetting something simple. Any help is appreciated.

denial of service – Rename files using lookup list – batch DOS

I have a list of files in a text file that I want to use for renaming:

File:
10664_padmin_abbh_encntr_20210412235959_1.txt,66010_padmin_10664_encntr_20210413000000_1.txt
10664_padmin_abbh_encntr_20210414235959_1.txt,66010_padmin_10664_encntr_20210415000000_1.txt

The file is currently named 10664_padmin_abbh_encntr_20210412235959_1.txt and I’d like it to be named 66010_padmin_10664_encntr_20210413000000_1.txt, then read the next line and continue until finished.

I have several hundred records so I’d like to batch this process.
Ideas?

windows – batch script create columns based on amount of files

I have a .txt-File which should be extended based on how many files there are in a folder.
The .txt-File looks like this:

---------------------------------------------------------------------------
File 1
---------------------------------------------------------------------------

File-Name...............:
File-Size...............:

---------------------------------------------------------------------------
File 2
---------------------------------------------------------------------------

File-Name...............:
File-Size...............: 

---------------------------------------------------------------------------
File x
---------------------------------------------------------------------------

File-Name...............:
File-Size...............: 

---------------------------------------------------------------------------

For further explanation of my question, let’s define one set of strings as one collumn:

---------------------------------------------------------------------------
File X
---------------------------------------------------------------------------

File-Name...............:
File-Size...............:

---------------------------------------------------------------------------

Now I want to a batch-Script to check for the amount of files inside the directory and
create copies of the collumn based on the amount of inside the directory to a local .txt-file.
It should also replace X with an ascending number.

This is my code so far:

@echo off

for /f %%A in ('dir /a-d-s-h /b ^| find /v /c ""') do set cnt=%%A
echo %CNT%

... //This is the lone where I want to copy the collumns based on the amount files

echo * >>test.txt //this is where I want to save it as a string

sql server – Key lock triggered by batch update

I’m doing a batch update operation,but it appears key lock I think I’m in trouble.
I don’t understand why the deadlock is happening.
enter image description here

Environment: SQL Server 2016

deadlock graph detailed:

<deadlock-list>
 <deadlock victim="process29617519088">
  <process-list>
   <process id="process29617519088" taskpriority="0" logused="0" waitresource="KEY: 14:72057594042122240 (aff034961e05)" waittime="2834" ownerId="59072177" transactionname="UPDATE" lasttranstarted="2021-04-12T16:50:19.377" XDES="0x295a2ef6e58" lockMode="U" schedulerid="7" kpid="7808" status="suspended" spid="91" sbid="2" ecid="0" priority="0" trancount="2" lastbatchstarted="2021-04-12T16:50:19.340" lastbatchcompleted="2021-04-12T16:50:19.343" lastattention="1900-01-01T00:00:00.343" clientapp="Core .Net SqlClient Data Provider" hostname="FENGL-PC" hostpid="1294251125" loginname="sa" isolationlevel="read committed (2)" xactid="59072177" currentdb="14" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
    <executionStack>
     <frame procname="adhoc" line="2" stmtstart="6" stmtend="942" sqlhandle="0x0200000010732f2ceb34267aaa1b31c44ae92e2ec57b3e1e0000000000000000000000000000000000000000">
unknown     </frame>
    </executionStack>
    <inputbuf>

 WITH Activitys AS (
 SELECT N'169489381063868436' AS Id,N'Name-2' AS Name,1 AS Version  
UNION ALL 
 SELECT N'169489381059674113' AS Id,N'Name-2' AS Name,1 AS Version  
UNION ALL 
 SELECT N'169489381013536784' AS Id,N'Name-2' AS Name,1 AS Version  
UNION ALL 
 SELECT N'169489381017731089' AS Id,N'Name-2' AS Name,1 AS Version) 
UPDATE S
SET S.Name = T.Name,
S.Version = S.Version + 1
FROM dbo.ActivityDto S JOIN Activitys T ON S.(Id)=T.(Id) AND S.(Version)=T.(Version);
 IF @@ROWCOUNT=4 BEGIN SELECT CAST(0 AS BIGINT) AS Id,0 AS Version END ELSE BEGIN
 WITH Ids AS (
 SELECT N'169489381063868436' AS Id 
UNION ALL 
 SELECT N'169489381059674113' AS Id 
UNION ALL 
 SELECT N'169489381013536784' AS Id 
UNION ALL 
 SELECT N'169489381017731089' AS Id) 

 SELECT S.Id,S.Version FROM dbo.ActivityDto S  JOIN Ids T ON S.(Id)=T.(Id) END    </inputbuf>
   </process>
   <process id="process295a1298ca8" taskpriority="0" logused="0" waitresource="KEY: 14:72057594042122240 (075b1091eea1)" waittime="2826" ownerId="59071581" transactionname="UPDATE" lasttranstarted="2021-04-12T16:50:19.353" XDES="0x2959a542e58" lockMode="U" schedulerid="9" kpid="5136" status="suspended" spid="139" sbid="2" ecid="0" priority="0" trancount="2" lastbatchstarted="2021-04-12T16:50:19.337" lastbatchcompleted="2021-04-12T16:50:19.343" lastattention="1900-01-01T00:00:00.343" clientapp="Core .Net SqlClient Data Provider" hostname="FENGL-PC" hostpid="1294251125" loginname="sa" isolationlevel="read committed (2)" xactid="59071581" currentdb="14" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
    <executionStack>
     <frame procname="adhoc" line="2" stmtstart="6" stmtend="1258" sqlhandle="0x020000006468c32fdcd8118755392016036171d4d3a33c1d0000000000000000000000000000000000000000">
unknown     </frame>
    </executionStack>
    <inputbuf>

 WITH Activitys AS (
 SELECT N'169489381063868437' AS Id,N'Name-2' AS Name,1 AS Version  
UNION ALL 
 SELECT N'169489381013536775' AS Id,N'Name-2' AS Name,1 AS Version  
UNION ALL 
 SELECT N'169489381013536789' AS Id,N'Name-2' AS Name,1 AS Version  
UNION ALL 
 SELECT N'169489381063868431' AS Id,N'Name-2' AS Name,1 AS Version  
UNION ALL 
 SELECT N'169489381009342465' AS Id,N'Name-2' AS Name,1 AS Version  
UNION ALL 
 SELECT N'169489381097422858' AS Id,N'Name-2' AS Name,1 AS Version) 
UPDATE S
SET S.Name = T.Name,
S.Version = S.Version + 1
FROM dbo.ActivityDto S JOIN Activitys T ON S.(Id)=T.(Id) AND S.(Version)=T.(Version);
 IF @@ROWCOUNT=6 BEGIN SELECT CAST(0 AS BIGINT) AS Id,0 AS Version END ELSE BEGIN
 WITH Ids AS (
 SELECT N'169489381063868437' AS Id 
UNION ALL 
 SELECT N'169489381013536775' AS Id 
UNION ALL 
 SELECT N'169489381013536789' AS Id 
UNION ALL 
 SELECT N'169489381063868431' AS Id 
UNION ALL 
 SELECT N'169489381009342465' AS Id 
UNION ALL 
 SELECT N'169489381097422858' AS Id) 

    </inputbuf>
   </process>
  </process-list>
  <resource-list>
   <keylock hobtid="72057594042122240" dbid="14" objectname="DbTest.dbo.ActivityDto" indexname="PK_ActivityDto" id="lock296177e3c80" mode="U" associatedObjectId="72057594042122240">
    <owner-list>
     <owner id="process295a1298ca8" mode="U"/>
    </owner-list>
    <waiter-list>
     <waiter id="process29617519088" mode="U" requestType="wait"/>
    </waiter-list>
   </keylock>
   <keylock hobtid="72057594042122240" dbid="14" objectname="DbTest.dbo.ActivityDto" indexname="PK_ActivityDto" id="lock295ac129d80" mode="U" associatedObjectId="72057594042122240">
    <owner-list>
     <owner id="process29617519088" mode="U"/>
    </owner-list>
    <waiter-list>
     <waiter id="process295a1298ca8" mode="U" requestType="wait"/>
    </waiter-list>
   </keylock>
  </resource-list>
 </deadlock>
</deadlock-list>

Activitydto table script

CREATE TABLE (dbo).(ActivityDto)(
    (Id) (bigint) NOT NULL,
    (ProcInstId) (bigint) NULL,
    (Name) (nvarchar)(500) NULL,
    (Version) (int) NULL,
 CONSTRAINT (PK_ActivityDto) PRIMARY KEY CLUSTERED 
(
    (Id) ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON (PRIMARY)
) ON (PRIMARY)
GO

I looked at two SQL statements and found no duplicate key, So I don’t understand what this is. Please let me know

2021-04-12 add:

lock res

waitresource="KEY: 14:72057594042122240 (aff034961e05)"

lockResKey Id ProcInstId
(aff034961e05) 169489381013536784 169489376328499300

waitresource="KEY: 14:72057594042122240 (075b1091eea1)"

lockResKey Id ProcInstId
(075b1091eea1) 169489381059674113 169489376324304968

execution plan:

https://www.brentozar.com/pastetheplan/?id=Hyd-39WUd

Explain SQL:
I will combine multiple pieces of data that need to be updated to form an update table, and then connect them together to do the update operation. If the number of affected rows is equal to the number of rows that I need to update, it means that all data updates are successful. If not, it means that some data updates fail. I need to query the current status of the data and return it to the program

thank