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

Author Topic: How can i copy a file name?  (Read 9007 times)

0 Members and 1 Guest are viewing this topic.

Mental

    Topic Starter


    Rookie

    How can i copy a file name?
    « on: February 23, 2008, 08:04:02 PM »
    hi
    i want copy a file name then with md command create a folder in same directory and rename the folder to name of file that copied ...
    eg:
    1 i have sample.txt
    2 i want copye this file name
    3 create sample folder in same directory

    i want type these in batch file ...

    GuruGary



      Adviser
      Re: How can i copy a file name?
      « Reply #1 on: February 23, 2008, 11:36:42 PM »
      What do you have so far, or where are you getting stuck?

      Mental

        Topic Starter


        Rookie

        Re: How can i copy a file name?
        « Reply #2 on: February 24, 2008, 04:05:26 AM »
        i want these for my program ...
        plz just tell me that how can i copy a file name?


        Dias de verano

        • Guest
        Re: How can i copy a file name?
        « Reply #3 on: February 24, 2008, 04:55:51 AM »
        What do you mean by "copy a file name"?

        Mental

          Topic Starter


          Rookie

          Re: How can i copy a file name?
          « Reply #4 on: February 24, 2008, 05:29:03 AM »
          i cant speak english very well
          copy file name in windows :



          i copied name of text file ( connection copied )
          now how can i do it in cmd ?

          Dias de verano

          • Guest
          Re: How can i copy a file name?
          « Reply #5 on: February 24, 2008, 05:31:21 AM »
          Why don't you do it in Windows? Cmd prompt does not have a clipboard.

          Is this right?

          In a folder you have 1 file only. if it is called sample.txt you want to create a folder there called sample?





          Mental

            Topic Starter


            Rookie

            Re: How can i copy a file name?
            « Reply #6 on: February 24, 2008, 05:48:44 AM »
            Quote
            In a folder you have 1 file only. if it is called sample.txt you want to create a folder there called sample
            yeah
            if i do it my problem 50% solved

            Dias de verano

            • Guest
            Re: How can i copy a file name?
            « Reply #7 on: February 24, 2008, 06:07:22 AM »
            what is the other 50%?

            Mental

              Topic Starter


              Rookie

              Re: How can i copy a file name?
              « Reply #8 on: February 24, 2008, 06:45:04 AM »
              dear friend
              if we cant solved this 50% , so we will cant  solve other 50% because related its ...

              Dias de verano

              • Guest
              Re: How can i copy a file name?
              « Reply #9 on: February 24, 2008, 06:48:05 AM »
              yes that is why I asked. They are related. So I need to know the whole problem. When asking for help in forums, it is a bad idea to be mysterious.

              WillyW



                Specialist
              • Thanked: 29
              • Experience: Experienced
              • OS: Windows XP
              Re: How can i copy a file name?
              « Reply #10 on: February 24, 2008, 12:17:27 PM »
              Quote
              In a folder you have 1 file only. if it is called sample.txt you want to create a folder there called sample
              yeah
              if i do it my problem 50% solved

              One way -    Use a free command line utility program.

              See:
              http://home.mnet-online.de/horst.muc/main.htm
              particularly:
              http://home.mnet-online.de/horst.muc/div.htm
              Check out    VARSET .

              It says it works under WinNt and Win2000.    I bet it works under XP too.
              You'd have to try it to be sure.

              It is simple to use.   Read the docs with it.

              With it, you can set an environment variable that is equal to a filename.
              Next, you could then use the   MD command along with that environment variable to create your new directory.
              I tried it under Win98SE.    Works fine.

              I hope this helps.

              .



              WillyW



                Specialist
              • Thanked: 29
              • Experience: Experienced
              • OS: Windows XP
              Re: How can i copy a file name?
              « Reply #11 on: February 24, 2008, 12:21:33 PM »
              Why don't you do it in Windows? Cmd prompt does not have a clipboard.

              Is this right?


              Side note:

              If ever you want to copy to/from the clipboard from the command line -  there is a free utility that will do it.

              See:
              http://home.mnet-online.de/horst.muc/div.htm#wclip
              and/or
              http://home.mnet-online.de/horst.muc/wbat32.htm

              I've tried Cliptext under '98 only.
              .



              Mental

                Topic Starter


                Rookie

                Re: How can i copy a file name?
                « Reply #12 on: February 24, 2008, 06:19:49 PM »
                Thx WillyW  :)
                i downloaded its , but im new dos user !!
                can you post that i how do with it ?? (For my problem ? )
                In a folder you have 1 file only. if it is called sample.txt you want to create a folder there called sample

                Dias de verano

                • Guest
                Re: How can i copy a file name?
                « Reply #13 on: February 25, 2008, 01:05:38 AM »
                I think what Mental wants is to get a batch file to load a filename into a variable, strip off the extension, and use what is left as the name of a folder which is to be created. This is easily done using batch commands.


                e.g.

                fmake "sample.txt"

                fmake.bat

                Quote
                set name=%~dpn1
                mkdir "%name%"

                makes dir called "sample"


                Mental

                  Topic Starter


                  Rookie

                  Re: How can i copy a file name?
                  « Reply #14 on: February 25, 2008, 03:34:19 AM »
                  thx mate
                  but i put this batch file with a txt file in same directory and i run the batch ...
                  but not any happend  :(

                  Dias de verano

                  • Guest
                  Re: How can i copy a file name?
                  « Reply #15 on: February 25, 2008, 03:53:05 AM »
                  did you call the batch file by name from the command line with the filename in quote marks?

                  try this

                  set name=%~n1
                  mkdir "%name%

                  Mental

                    Topic Starter


                    Rookie

                    Re: How can i copy a file name?
                    « Reply #16 on: February 25, 2008, 04:40:25 AM »
                    its not work with double click ...
                    its not work with call from cmd
                    (batch file )

                    Dias de verano

                    • Guest
                    Re: How can i copy a file name?
                    « Reply #17 on: February 25, 2008, 04:48:35 AM »
                    did you do all these?

                    1. save the batch as fmake.bat in the same folder
                    2. Open a dos command box in that folder.
                    3. If the text file is called (for example) sample.txt you type

                    fmake "sample.txt"


                    Mental

                      Topic Starter


                      Rookie

                      Re: How can i copy a file name?
                      « Reply #18 on: February 25, 2008, 06:10:16 AM »
                      thx a lot of
                      i wanted this (My Progress 30%) :)
                      but we have a problem , i want that if i run fmake (in cmd like above post) it automatically create sample folder ...
                      in above way i must type manually ...
                      im waitig for your answer  ::)

                      Dias de verano

                      • Guest
                      Re: How can i copy a file name?
                      « Reply #19 on: February 25, 2008, 06:22:35 AM »
                      is there just 1 file in the folder?

                      Mental

                        Topic Starter


                        Rookie

                        Re: How can i copy a file name?
                        « Reply #20 on: February 25, 2008, 06:44:00 AM »
                        no
                        but there 1 txt file

                        Dias de verano

                        • Guest
                        Re: How can i copy a file name?
                        « Reply #21 on: February 25, 2008, 06:51:06 AM »
                        only ever 1 text file, and that is the file whose name you want to use for the folder name

                        for example

                        find example9999.txt ===>>> make folder example9999

                        Is this the task?

                        Mental

                          Topic Starter


                          Rookie

                          Re: How can i copy a file name?
                          « Reply #22 on: February 25, 2008, 06:55:23 AM »
                          yeah, exactly

                          Dias de verano

                          • Guest
                          Re: How can i copy a file name?
                          « Reply #23 on: February 25, 2008, 07:02:33 AM »
                          try this, run it in the same directory

                          @echo off
                          setlocal enabledelayedexpansion
                          for /f "delims==" %%F in ('dir/b *.txt') do (
                          echo found text file: %%F
                          make folder called  : %%~nF
                          md %%~nF
                          pause


                          Mental

                            Topic Starter


                            Rookie

                            Re: How can i copy a file name?
                            « Reply #24 on: February 25, 2008, 07:09:56 AM »
                            i copied the code in batch file in same directory with a txt file ... then run the batch file
                            but not any happend

                            Dias de verano

                            • Guest
                            Re: How can i copy a file name?
                            « Reply #25 on: February 25, 2008, 07:12:18 AM »
                            I missed a space and a character out. Sorry.

                            @echo off
                            setlocal enabledelayedexpansion
                            for /f "delims==" %%F in ('dir /b *.txt') do (
                            echo found text file: %%F
                            make folder called  : %%~nF
                            md %%~nF
                             
                              )

                            pause

                            Dias de verano

                            • Guest
                            Re: How can i copy a file name?
                            « Reply #26 on: February 25, 2008, 07:19:15 AM »
                            Mistakes hopefully corrected!

                            Quote

                            @echo off
                            setlocal enabledelayedexpansion
                            for /f "delims==" %%F in ('dir /b *.txt') do (
                               echo found text file  : %%F
                               echo will make folder : %%~nF
                               if not exist "%%~nF" md "%%~nF"
                               )
                            pause



                            Mental

                              Topic Starter


                              Rookie

                              Re: How can i copy a file name?
                              « Reply #27 on: February 25, 2008, 07:21:05 AM »
                              ohh very thx ..
                              we victory on dos !
                              but plz see this ?
                              can u remove some bugs?

                              Dias de verano

                              • Guest
                              Re: How can i copy a file name?
                              « Reply #28 on: February 25, 2008, 07:23:27 AM »
                              use my corrected version

                              delete folder called g

                              try again


                              Mental

                                Topic Starter


                                Rookie

                                Re: How can i copy a file name?
                                « Reply #29 on: February 25, 2008, 07:31:45 AM »
                                ok
                                thx for help me ,
                                im writting a program , for some problem i had changed my method ...
                                but i will return to old method ...
                                now my progress is over 60%
                                if i encounter problem i will come back ...
                                ThX in advance dear friend