[-] BobTheDestroyer@lemy.lol 1 points 3 months ago

Just words? It's a list of names.

4

I have a script that duplicates a Word doc template and renames each using a csv file with a list of names. What would be the equivalent code if instead of a csv file I use a text file?

Import-csv ‘.\individuals2.csv’ | foreach-object {
	$newname = ‘2 ‘ + $_.name + '.docx’
	Copy-item '.\template.docx' $newname
}
[-] BobTheDestroyer@lemy.lol 1 points 3 months ago

It manages to output one file titled 'name; 0++'

[-] BobTheDestroyer@lemy.lol 1 points 3 months ago

Thanks but I'm getting a 'Cannot create a file when that file already exists.' error. I checked the path so I am certain it is correct.

[-] BobTheDestroyer@lemy.lol 1 points 3 months ago

Perhaps my directions were unclear. The Excel/CSV file has the new names and I want to use them to replace the default names for the PDF files.

[-] BobTheDestroyer@lemy.lol 2 points 3 months ago

I got rid of that task. Now it's just Task #1

[-] BobTheDestroyer@lemy.lol 1 points 3 months ago
[-] BobTheDestroyer@lemy.lol 2 points 3 months ago

Nevermind I got it!

11
submitted 3 months ago* (last edited 3 months ago) by BobTheDestroyer@lemy.lol to c/powershell@programming.dev

Note: I'm a beginner to Powershell and a bit more familiar with Bash (though still a beginner for that too).

*I have multiple PDF files and I want to rename each file based on a list of names found in an Excel/CSV (could be a text file if easier) file.

*The list begins at the A2 cell and the A1 cell has the header 'name'.

*The files are in sequential order and match the order of the list of names.

Thanks for your help!

[-] BobTheDestroyer@lemy.lol 1 points 3 months ago

Actually nevermind that question. Just realized the command was split.

I'm assuming I need to replace the name portion of the 2nd line. What do I input if the data is a list that starts in A1?

[-] BobTheDestroyer@lemy.lol 1 points 3 months ago

So I'm new to all this. When I enter the first command with my csv file and doc file included, it just opens the word doc. Wasn't sure what I should do next.

[-] BobTheDestroyer@lemy.lol 1 points 3 months ago

Sorry I'm new to this. What exactly do I enter into Powershell for each step?

[-] BobTheDestroyer@lemy.lol 2 points 3 months ago

It does have to be a Word template. It has a bar graph and various texts.

10

I'm a beginner to Powershell and CLI in general, but this task does not need to use either so I'm open to using other tools.

I'm trying to do the following:

  1. Create multiple files from a Word template.
  2. Rename each file based on a list of names found in an Excel/CSV sheet.

Thanks in advance!

view more: next ›

BobTheDestroyer

joined 3 months ago