Jump to content

Saving directory list


Recommended Posts

I wanted to make a script which saves the list of files in a folder (dir excluding subfolder) only filea with prefix of custom location in text file

Like

My folder A has file 1.txt, 2.jpg, 3.png etc

Prefix to add "http://website/doc/"

so when i run the script it should save the txt file as

http://website/doc/1.txt

http://website/doc/2.jpg

http://website/doc/3.png

i think friend u got my point this can be done through batch file even but i dont know how, and to create a script

i created a batch with commands but didnt get the desire result

command was

@echo off

dir /p >filelist.txt

but this is not what i want

Help needed ! :D

Link to comment
Share on other sites

  • Moderators

kashifabb,

Welcome to the AutoIt forum. :)

What you want to do is very easy in AutoIt. Look at the following functions in the Helpfile:

_FileListToArray - gets an array listing of the files in the folder.

For...Next - lets you loop through the array so you can add the prefix using the & operator

_FileWriteFromArray - write the array to file

Give it a go yourself and see how you get on - you know where we are if you run into difficulties. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

try this:

#include <File.au3>
#include <Array.au3>
Local $sFile = @ScriptDir & "\Test.txt"
Local $FileListxt = _FileListToArray(@DesktopDir)
local $i=1
Local $prefi="http://website/doc/"
If @error = 1 Then
MsgBox(0, "", "No Folders Found.")
Exit
EndIf
If @error = 4 Then
MsgBox(0, "", "No Files Found.")
Exit
EndIf

_ArrayDisplay($FileListxt)

for $i=1 to $FileListxt[0]
$FileListxt[$i]=$prefi&$FileListxt[$i]
next
_ArrayDisplay($FileListxt)

_FileWriteFromArray($sFile,$FileListxt,1)

regards

Link to comment
Share on other sites

Thanks alot my dear Melba23 and Danyfirex

And dear danyfirex thanks much, bcoz i dont wanted to go through loops and direcctory studies though i will later on, so ur code was real help

Thanks guys :)

But Freind there is only one problem

My files are suppossed located in

"C:userpublicpic" and this folder contains files 1.txt, 2.jpg, 3.png etc

Prefix to add "http://website/doc/" and if poosible popup dialog to ask for this location at start of this script so if change to change prefix can easily.

when saving file it should trim "c:userpublic" but keep "pic" and change to forward lash (means should keep whatever comes after "public")

And save filelist as "http://website/doc/pic/1.txt"

Edited by kashifabb
Link to comment
Share on other sites

kashifabb,

Welcome to the AutoIt forum. :)

Give it a go yourself and see how you get on - you know where we are if you run into difficulties. :)

M23

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

You will get the same response from most, if not, all member here. We try to help when we can, but are not going to do all the work. Melba23 gave you a good starting point, and you were given most of the code to do what you want to do - so if you put a little effort into your project - you will get a better response.

I know some members would just tell you to got to www.rentacoder.com/ for what you want.

EDIT

I just reread what you are looking to do. I am not sure we are on the same page. Are you trying to get a list created of the files? And the last part where you want to save them back to HTTP - that is not going to be possible. You might be able to save them to FTP, but that does not look like what you want.

Maybe break it down a little better - what you are trying to do, cause you are not going to be able to save the files. But you can save a listing of said files - is that what you are looking to do?

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...