As part of an NSIS script builder I have a list of filenames that are currently in a file called files.txt. An example of the content is below...

```
c:\myfolder\assets\startup.xml
c:\myfolder\assets\begin.exe
c:\myfolder\assets\begin.swf
c:\myfolder\assets\resources\assets\text\help.pdf
c:\myfolder\assets\resources\assets\text\license.rtf
c:\myfolder\assets\resources\assets\swf\piano.swf
c:\myfolder\assets\resources\assets\swf\numbers.swf
c:\myfolder\assets\resources\section1\resource1\item1.jpg
c:\myfolder\assets\resources\section1\resource1\item2.jpg
c:\myfolder\assets\resources\section4\resource1\item7.jpg
c:\myfolder\assets\resources\section4\resource1\item8.jpg

```

I am trying to process this list of files using a batch file so that they end up looking like this...

```
SetOutPath "$INSTDIR"
File "c:\myfolder\assets\startup.xml"
SetOutPath "$INSTDIR"
File "c:\myfolder\assets\begin.exe"
SetOutPath "$INSTDIR"
File "c:\myfolder\assets\begin.swf"
SetOutPath "$INSTDIR\resources\assets\text"
File "c:\myfolder\assets\resources\assets\text\help.pdf"
SetOutPath "$INSTDIR\resources\assets\text"
File "c:\myfolder\assets\resources\assets\text\license.rtf"
SetOutPath "$INSTDIR\resources\assets\swf"
File "c:\myfolder\assets\resources\assets\swf\piano.swf"
SetOutPath "$INSTDIR\resources\assets\swf"
File "c:\myfolder\assets\resources\assets\swf\numbers.swf"
SetOutPath "$INSTDIR\resources\section1\resource1"
File "c:\myfolder\assets\resources\section1\resource1\item1.jpg"
SetOutPath "$INSTDIR\resources\section1\resource1"
File "c:\myfolder\assets\resources\section1\resource1\item2.jpg"
SetOutPath "$INSTDIR\resources\section4\resource1"
File "c:\myfolder\assets\resources\section4\resource1\item7.jpg"
SetOutPath "$INSTDIR\resources\section4\resource1"
File "c:\myfolder\assets\resources\section4\resource1\item8.jpg"

```

I have tried a few things but haven't really been able to find a solution. Can anyone point me in the right direction?

**UPDATE**

Ok, so going on from Aacini's post I have modified the batch file slightly as below...

```
dir "c:\n\assets" /b /s > "c:\n\original.txt"
type "c:\n\original.txt" | findstr \. > "c:\n\filelist.txt"
@echo off
setlocal EnableDelayedExpansion
SET PATH=C:\n
set INSTDIR="c:\n\assets\"
( for /F "delims=" %%a in (filelist.txt) do (
     set "filePath=%%~DPa"
     set "outPath=!filePath:%INSTDIR%=!"
     if defined outPath set "outPath=\!outPath:~0,-1!"
     echo SetOutPath "$INSTDIR!outPath!"
     echo File "%%a"
  )
) > "c:\n\result.txt"
REM move /Y c:\result.txt files.txt

```

I made a couple of changes mainly with quotes to allow spaces to be used in the path names, and I also set the path to allow everything to work correctly when being called from NSIS. The problem I am facing now is that instead of....

```
SetOutPath "$INSTDIR\assets"
File "c:\my folder\assets\startup.xml"

```

I get....

```
SetOutPath "$INSTDIR\c:\my folder\assets"
File "c:\my folder\assets\startup.xml"

```

I imaging it is a real easy fix to resolve but I am pulling my hair out trying to change it! What am I doing wrong?