You can make a function and use it:
pathToFiles = "/yourPath/..";
SetDirectory[pathToFiles];
newPath = FileNameJoin[{pathToFiles, "newPath"}];
If[!DirectoryQ[newPath],
CreateDirectory[newPath];
];
files = FileNames["*.jpg", pathToFiles];
Export[FileNameJoin[{newPath, FileNameTake[#, -1]}], customFunc@Import[#]] & /@ files
Now, your customFunc
customFunc[img_Image] :=
Block[{dims, dirs, magnitudes, orientations},
dims = ImageDimensions[img];
dirs = ImageData[GradientOrientationFilter[img, 5]];
magnitudes = ImageData[GradientFilter[img, 5]];
orientations = MapThread[#1 {-Sin[#2], Cos[#2]} &, {magnitudes, dirs}, 2];
ListVectorPlot[
MapIndexed[{{#2[[2]], dims[[2]] - #2[[1]]}, #1} &, orientations, {2}],
VectorColorFunction -> (Yellow &)
]
]