Page 1 of 1

need to add header and add a formula

Posted: 23 Oct 2022 23:42
by key
@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

Re: need to add header and add a formula

Posted: 24 Oct 2022 08:54
by aGerman
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

Re: need to add header and add a formula

Posted: 24 Oct 2022 21:27
by key
I have attached the csv files.

Re: need to add header and add a formula

Posted: 25 Oct 2022 03:41
by ShadowThief
How do you know which "formula" goes with which column? It feels completely arbitrary.

Re: need to add header and add a formula

Posted: 25 Oct 2022 04:03
by key
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)

Re: need to add header and add a formula

Posted: 25 Oct 2022 04:53
by ShadowThief
You're going to want VBA for this. Batch can't help with Excel.

Re: need to add header and add a formula

Posted: 25 Oct 2022 05:06
by key
can add column header using batch?

i will copy paste the formula