Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
md73code
- Posts: 16
- Joined: 29 Jul 2015 15:29
#16
Post
by md73code » 22 Sep 2017 10:16
Squashman wrote:Manveer Dhillon wrote:Antonio, thank you for outlining the details required from me when writing problems on the forums. I will pay closer attention to the information that is required from me in order to acquire proper support from this community. I tried your code and placed the .bat file in the same directory as my .csv files however no renaming output was being generated. I also tried running the .bat file as administrator. Is there a certain way I should be running your code?
Look at this line of code:
Code: Select all
ECHO ren "%%f" "%%~Nf_!col7!-!avg7:~-7,1!.!avg7:~-6!_!col8!-!avg8:~-7,1!.!avg8:~-6!.csv"
What would you do to change that line of code to make it work for your needs?
Hi Squashman, I was hoping I was not going to be asked to decipher some of the code here
a lot of the code that has ben used so far on this topic is so above and beyond my simple .bat file skills. From looking at that line I can see 2 parts, "%%f" and "%%~Nf_!col7!-!avg7:~-7,1!.!avg7:~-6!_!col8!-!avg8:~-7,1!.!avg8:~-6!.csv". I think the 2nd part is fine as those are the right column numbers, but I'm not sure if "%%f" is doing what I want to initiate the renaming?
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#17
Post
by Squashman » 22 Sep 2017 10:21
Manveer Dhillon wrote:Hi Squashman, I was hoping I was not going to be asked to decipher some of the code here
a lot of the code that has ben used so far on this topic is so above and beyond my simple .bat file skills. From looking at that line I can see 2 parts, "%%f" and "%%~Nf_!col7!-!avg7:~-7,1!.!avg7:~-6!_!col8!-!avg8:~-7,1!.!avg8:~-6!.csv". I think the 2nd part is fine as those are the right column numbers, but I'm not sure if "%%f" is doing what I want to initiate the renaming?
You are way over thinking it. What is the first word of that line of code and what does that command do?
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#18
Post
by aGerman » 22 Sep 2017 10:41
Manveer Dhillon wrote:I was hoping I was not going to be asked to decipher some of the code here
Don't get me wrong but
we are hoping that the support we give is a help to help yourself and that you're able to understand and adjust the code in case it doesn't meet your needs precisely enough. DosTips is not RentACoder
Execute
FOR /? to see how the modifiers of FOR variables work.
Execute
SET /? to see what the syntax for substrings is.
Also remember what ECHO ist doing.
Requesting a little own initiative is surely not asking too much, is it?
Steffen
-
md73code
- Posts: 16
- Joined: 29 Jul 2015 15:29
#19
Post
by md73code » 22 Sep 2017 11:20
You are right. I will take more of an initiative to try and learn/understand the code being provided here. I'll write back when I have a better grasp and understanding of the solutions and update the thread with the changes I made to get this working. Thanks.
-
md73code
- Posts: 16
- Joined: 29 Jul 2015 15:29
#20
Post
by md73code » 25 Sep 2017 12:03
Squashman wrote:Manveer Dhillon wrote:Hi Squashman, I was hoping I was not going to be asked to decipher some of the code here
a lot of the code that has ben used so far on this topic is so above and beyond my simple .bat file skills. From looking at that line I can see 2 parts, "%%f" and "%%~Nf_!col7!-!avg7:~-7,1!.!avg7:~-6!_!col8!-!avg8:~-7,1!.!avg8:~-6!.csv". I think the 2nd part is fine as those are the right column numbers, but I'm not sure if "%%f" is doing what I want to initiate the renaming?
You are way over thinking it. What is the first word of that line of code and what does that command do?
"@ echo off" won't print out this code to console. The last line with "ECHO" ren .. should print to the data to .csv filename.
-
Aacini
- Expert
- Posts: 1913
- Joined: 06 Dec 2011 22:15
- Location: México City, México
-
Contact:
#21
Post
by Aacini » 26 Sep 2017 10:55
IMHO you have a fundamental confusion here that is reflected in the topic title and in your last phrase ("should print to the data to .csv filename").
The "print result" phrase means display or show a text in the screen. The command used to print/display/show results in the screen is ECHO. There is no way to "print result" to a file name (a file name is NOT the screen).
A file name may be modified/altered/changed, but the technical term for such an action is renamed. The command used to rename a file name is REN.
If you want to change the file name, use the REN command (not the ECHO command).
The "command" is the first word that appear in each line of a Batch file...
-
md73code
- Posts: 16
- Joined: 29 Jul 2015 15:29
#22
Post
by md73code » 04 Oct 2017 16:30
Aacini wrote:IMHO you have a fundamental confusion here that is reflected in the topic title and in your last phrase ("should print to the data to .csv filename").
The "print result" phrase means display or show a text in the screen. The command used to print/display/show results in the screen is ECHO. There is no way to "print result" to a file name (a file name is NOT the screen).
A file name may be modified/altered/changed, but the technical term for such an action is renamed. The command used to rename a file name is REN.
If you want to change the file name, use the REN command (not the ECHO command).
The "command" is the first word that appear in each line of a Batch file...
I follow your explanation, I'm still struggling with what needs to be changed on the last line of code. I understand that the "REN" command will alter the filename with the parameters given to it, but I'm not sure why it won't rename the files with the results data.
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#23
Post
by Squashman » 05 Oct 2017 08:27
Maybe this will clear up the confusion on what the
ECHO command does and what the
REN command does.
Code: Select all
H:\echotest>dir /B
myfile.txt
H:\echotest>echo ren myfile.txt squashman.txt
ren myfile.txt squashman.txt
H:\echotest>dir /b
myfile.txt
H:\echotest>ren myfile.txt squashman.txt
H:\echotest>dir /b
squashman.txt
H:\echotest>