need to add header and add a formula

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
key
Posts: 11
Joined: 23 Oct 2022 23:36

need to add header and add a formula

#1 Post by key » 23 Oct 2022 23:42

@echo off
SET "CDIR=%~dp0"
:: for loop requires removing trailing backslash from %~dp0 output
SET "CDIR=%CDIR:~0,-1%"
FOR %%i IN ("%CDIR%") DO SET "PARENTFOLDERNAME=%%~nxi"
ECHO Parent folder: %PARENTFOLDERNAME%
dir /b /o:n *.tif *.eps *.png *.jpg > %PARENTFOLDERNAME%.csv
exit

--------------------------------
Headers Column A1"Find" Column B1"Change"
List files in B1"Change"

Add a formula in A1"Find"

Input and Output files in the link below.

Input file https://fromsmash.com/aAOU6Hv3py-dt

Output file https://fromsmash.com/5LPuvbLuTL-dt

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: need to add header and add a formula

#2 Post by aGerman » 24 Oct 2022 08:54

I've seen that both your input and output files are .xlsx. This is a compressed file format that batch is not able to work with.

Steffen

key
Posts: 11
Joined: 23 Oct 2022 23:36

Re: need to add header and add a formula

#3 Post by key » 24 Oct 2022 21:27

I have attached the csv files.
Attachments
Input-file.csv
Input File
(296 Bytes) Downloaded 352 times
Output-file.csv
Output File
(409 Bytes) Downloaded 308 times

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: need to add header and add a formula

#4 Post by ShadowThief » 25 Oct 2022 03:41

How do you know which "formula" goes with which column? It feels completely arbitrary.

key
Posts: 11
Joined: 23 Oct 2022 23:36

Re: need to add header and add a formula

#5 Post by key » 25 Oct 2022 04:03

need to add this formula in below row of Find Header:

=INDEX({"IFig";"SFig";"Fig";"CFig"},MATCH(MID(LEFT(B2,FIND(".",$B2)-1),10,1),{"a";"s";"f";"c"},0)) & VALUE(MID(LEFT(B2,FIND(".",$B2)-1),11,2)) & MID(LEFT(B2,FIND(".",$B2)-1),13,99)

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: need to add header and add a formula

#6 Post by ShadowThief » 25 Oct 2022 04:53

You're going to want VBA for this. Batch can't help with Excel.

key
Posts: 11
Joined: 23 Oct 2022 23:36

Re: need to add header and add a formula

#7 Post by key » 25 Oct 2022 05:06

can add column header using batch?

i will copy paste the formula

Post Reply