Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch list and create a txt from listing inside another txt!  (Read 4397 times)

0 Members and 1 Guest are viewing this topic.

zylor

    Topic Starter


    Newbie

    • Experience: Experienced
    • OS: Windows 7
    Batch list and create a txt from listing inside another txt!
    « on: January 15, 2013, 11:19:11 AM »
    Hi!

    I created a batch file to list every .apk file inside that same directory!

    with the code:

    Code: [Select]
    @echo
    for /r . %%g in (*.apk) do echo %%~nxg >> list.txt

    The final listing (list.txt) is for example:

    Code: [Select]
    AccuweatherDaemon.apk
    AccuWeatherDaemonService.apk
    AccuweatherWidget.apk
    AccuweatherWidget_Main.apk

    After i get this listing i created another batch to create a specific code to create specific list for the files inside the list.txt:

    Code: [Select]
    @echo off
    for /f "tokens=*" %%A in (list.txt) do (
    echo.symlink("/preload/symlink/system/app/%%~nA.apk","/system/app/%%~nA.apk"); >> symlinks.txt
    )

    And i wanted  the final listing to appear as:

    Code: [Select]
    symlink("/preload/symlink/system/app/AccuweatherDaemon.apk","/system/app/AccuweatherDaemon.apk");
    symlink("/preload/symlink/system/app/AccuWeatherDaemonService.apk","/system/app/AccuWeatherDaemonService.apk");
    symlink("/preload/symlink/system/app/AccuweatherWidget.apk","/system/app/AccuweatherWidget.apk");
    symlink("/preload/symlink/system/app/AccuweatherWidget_Main.apk","/system/app/AccuweatherWidget_Main.apk");

    But what i get is:

    Code: [Select]
    symlink("/preload/symlink/system/app/AccuweatherDaemon.apk","/system/app/AccuweatherDaemon.apk"
    symlink("/preload/symlink/system/app/AccuWeatherDaemonService.apk","/system/app/AccuWeatherDaemonService.apk"
    symlink("/preload/symlink/system/app/AccuweatherWidget.apk","/system/app/AccuweatherWidget.apk"
    symlink("/preload/symlink/system/app/AccuweatherWidget_Main.apk","/system/app/AccuweatherWidget_Main.apk"

    Somehow the ); is getting ignored!

    Anyone know how to fix it?

    Thanks

    DigitalSnow



      Greenhorn

    • Keep It Simple
    • Thanked: 3
      • Certifications: List
      • Experience: Experienced
      • OS: Windows 7
      Re: Batch list and create a txt from listing inside another txt!
      « Reply #1 on: January 15, 2013, 11:24:00 AM »
      Code: [Select]
      @echo off
      for /f "tokens=*" %%A in (list.txt) do (
      echo.symlink("/preload/symlink/system/app/%%~nA.apk","/system/app/%%~nA.apk"^); >> symlinks.txt
      )

      Add an escape character ^ before the ) close parentheses character.   ) is being interpreted as the end of the loop because it is a special character.  Escaping needs to be done for all special characters used as literals not contained within double quotations.

      zylor

        Topic Starter


        Newbie

        • Experience: Experienced
        • OS: Windows 7
        Re: Batch list and create a txt from listing inside another txt!
        « Reply #2 on: January 15, 2013, 11:26:22 AM »
        I was just replying my own post with the exact same solution as you provided my friend!

        I remembered about the special characters too!

        And then i found this post:

        http://stackoverflow.com/questions/10021464/batch-file-to-add-characters-to-beginning-and-end-of-each-line-in-txt-file

        Which clarified everything to me  ;D

        Thanks for your help!